I noticed that when I create sets in Python, they don't seem to maintain any specific order. For example, when I create a set like this:
```python
a = set ([4, 2, 1, 1, 3])
print (a) # Output: {1, 2, 3, 4}
print ("Set b is: ", set ([5, 2, 1, 1, 3])) # Set b is: {1, 2, 3, 5}
print ("Set c is: ", set ([8, 5, 6, 7, 7])) # Set c is: {8, 5, 6, 7}
```
I expected set c to be ordered from smallest to largest, but it's not. Why does this happen?
3 Answers
Sets in Python are unordered by nature, meaning they don't guarantee a specific sequence. Just because one set prints in an ordered way doesn't mean another will do the same.
Sets eliminate duplicates and aren't meant for maintaining a particular order. If you need to keep items in a sequence, using a list (or array) would be the way to go.
The design of sets is to be fast when checking for membership and preventing duplicates, not to maintain order like lists do. If order is essential, you could convert it to a sorted list using the sorted function.

Exactly! You can sort a set with:
```python
print (sorted(set([8, 5, 6, 7, 7])))
``` That's a straightforward way to achieve an ordered list from a set!