As of Python 3.7, dict objects maintain their insertion order by default.
If you’re on Python 2.7 or Python >=3.1 you can use collections.OrderedDict in the standard library.
This answer to the question How do you retrieve items from a dictionary in the order that they’re inserted? contains an implementation of an ordered dict, in case you’re not using Python 3.x and don’t want to give yourself a dependency on the third-party ordereddict module.