Here is a simple program that appends integers to a set in Python 3:
s = set()
for i in range(10):
s.add(i*47)
Naturally I would expect the result to be: 0 47 94 141 188 235 282 329 376 423
In fact, the result is: 0 423 329 235 141 47 376 282 188 94
So the output is re-ordered in some way that is not consistent. It's not sorted or reordered in any way I can intuit.
I've done research but I haven't found an answer to this simple question. When I use set.add, in what order are the elements added? How and why are they re-sorted this way?