I recently watched Raymond Hettingers talk about python dictionaries (and by extension sets...) and he mentioned that integers hash to themselves and that adding integers to a dict (or set...) will insert them in order and as long as you don't delete items the order will be preserved in python 3.6 (and probably above?). In the answer to this question it is stated that dictionaries preserve order of insertion, but for sets it seams like integers are ordered according to their value.
Now: according to the time-complexity section of python.org and in more detail here it is stated that the average time-complexity of adding an element to a set is O(1). This means if you have an unsorted list of integers it should be possible to sort them by simply doing:
sorted_list = list(set(unsorted_list))
This seams to be the case as far as I have tested it (did it a few 1000 times with random sequences).
My question is now: Does this mean it is possible to sort integers in python in O(n) time?
To me it would seam so, as it takes O(n) to build the set and O(n) to convert the set back to a list or am I missing something here?