import pprint
a = {'c': 2, 'b': 3, 'y': 5, 'x': 10}
pp = pprint.PrettyPrinter(sort_dicts=True)
pp.pprint(a)
# Output:
# {'b': 3, 'c': 2, 'x': 10, 'y': 5}
import pprint
a = {'c': 2, 'b': 3, 'y': 5, 'x': 10}
pp = pprint.PrettyPrinter(sort_dicts=True)
pp.pprint(a)
# Output:
# {'b': 3, 'c': 2, 'x': 10, 'y': 5}