I thought it was a coincidence at first so I wrote up a test to try it out and it's true, I ran it 1 million times and every single time the set came back ordered and sorted. This only occurs when you use integers from 0-9 as soon as an integer > 9 is inserted then any integers inserted after will not be sorted. Why is this? Also for floats it kind of sorts it but isn't right all the time, so weird I thought they were completely unordered. Any advice on why 0-9 is sorted every time would be greatly appreciated, I didn't believe it at first either so here's the code I used you can easily run it yourself and see it's true.
import random
def check_set():
constructing = True
s = set()
while constructing:
x = random.randint(0, 9)
if x not in s: s.add(x)
if len(s) == 10: constructing = False
return s
def main():
for x in range(10000):
l = list(check_set())
if l != [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]:
print('wow')
if __name__ == '__main__':
main()