Show that Python dictionaries preserve insertion order, and what happens when you update or re-add a key.
Dictionaries keep their keys in the order that you added them. When you walk through a dictionary with a for loop, you see the keys in the order they were first inserted. This has been true since Python 3.7, and the language specification now promises it.
data = {}
data['b'] = 2
data['a'] = 1
data['c'] = 3
print(list(data)) # ['b', 'a', 'c'] - the order they were added
# Updating a key keeps the place it already had.
data['b'] = 20
print(list(data)) # ['b', 'a', 'c']
# Deleting a key and adding it again moves it to the end.
del data['b']
data['b'] = 20
print(list(data)) # ['a', 'c', 'b']
The first print shows the insertion order and not the alphabetical order, so the dictionary is definitely not sorted. The second print shows that updating a key does not move it, because the key keeps the position it was first given. The third print shows that deleting a key and then adding it again puts it at the end, because that second addition is a brand new insertion.
Two results are worth stating clearly. First, the order is stable and it is reproducible, so two dictionaries that were built by the same code are walked in the same sequence. That is what makes log output and test checks predictable. Second, the order is guaranteed but it is not a sorting guarantee. If you need the keys in alphabetical order, you have to ask for it with sorted(data) or sorted(data.items()).
The same rules apply to the keys view, the values view, and the items view, because they all walk the dictionary in the same underlying order. Sets are different here. The order of a set is steady for a given set of values inside one run of the program, but it is not the insertion order and you must never rely on it.