Fix issue when using set to remove duplicates mess up the sorting of the exported output