You can download this code by clicking the button below.
This code is now available for download.
This function sorts the dictionary items by their values and returns a new dictionary with the items ordered by the sorted values.
Technology Stack : Built-in function sorted, lambda expressions, tuple unpacking
Code Type : Sort function
Code Difficulty : Intermediate
def sort_dict_by_value(d):
return dict(sorted(d.items(), key=lambda item: item[1]))