Recently I noticed that when I am converting a list to set the order of elements is changed and is sorted by character.
list
set
Consider this examp
remove duplicates and preserve order by below function
def unique(sequence): seen = set() return [x for x in sequence if not (x in seen or seen.add(x))]
check this link