Let's run the following code:
st = {3, 1, 2}
st
>>> {1, 2, 3}
st.pop()
>>> 1
st.pop()
>>> 2
st.pop()
>>> 3
Although sets are said to be unordered, this set behaves as if it was sorted in ascending order. The method pop()
, that should return an 'arbitrary element', according to the documentation, returns elements in ascending order as well. What is the reason for this?