You can download this code by clicking the button below.
This code is now available for download.
This function takes a dictionary as input and returns a new dictionary with the keys sorted alphabetically.
Technology Stack : Sorting
Code Type : Sort function
Code Difficulty : Intermediate
def sort_dict_by_key(d):
return {k: d[k] for k in sorted(d)}