I like the pprint module in Python. I use it a lot for testing and debugging. I frequently use the width option to make sure the output fits nicely within my terminal window
As of Python 3.8 : pprint.PrettyPrinter exposes the sort_dicts keyword parameter.
True by default, setting it to False will leave the dictionary unsorted.
>>> from pprint import PrettyPrinter
>>> x = {'John': 1,
>>> 'Mary': 2,
>>> 'Paul': 3,
>>> 'Lisa': 4,
>>> }
>>> PrettyPrinter(sort_dicts=False).pprint(x)
Will output :
{'John': 1,
'Mary': 2,
'Paul': 3,
'Lisa': 4}
Reference : https://docs.python.org/3/library/pprint.html