0

The documentation clearly says sets are unordered, but this bit of code:

{5,2,3,7,7,5,2,3}

Yields:

set([2, 3, 5, 7])

Iterating through {5,2,3,7,7,5,2,3} also displays the numbers in order.

So which is it: ordered or unordered? Clarification appreciated.

Wells
  • 10,415
  • 14
  • 55
  • 85
  • 4
    They don't *maintain* order. The order the elements are iterated over is entirely down to implementation details and should not be relied upon. – Martijn Pieters Jan 07 '16 at 22:14
  • 1
    Try `{1, 2, 3, 88}`. – timgeb Jan 07 '16 at 22:16
  • The order of sets is implementation-dependent. So it could be that in your implementation, sets are ordered, but not in another, and maybe not also the next time you will try – arainone Jan 07 '16 at 22:39

0 Answers0