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
In Python 3.6, set() now should keep the order, but there is another solution for Python 2 and 3:
set()
>>> x = [1, 2, 20, 6, 210] >>> sorted(set(x), key=x.index) [1, 2, 20, 6, 210]