Fix issue where List or Set were not being correctly sorted