You can download this code by clicking the button below.
This code is now available for download.
The function accepts a dictionary as an argument and returns a new dictionary. The new dictionary has key-value pairs sorted by dictionary order of the keys.
Technology Stack : Standard library data types and dictionaries
Code Type : Function
Code Difficulty : Intermediate
def aordict(d):
return {k: aordict(v) if isinstance(v, dict) else v for k, v in sorted(d.items())}