sort list of dict by key code example
Example 1: sort list of dictionaries python
unsorted_list = [{"key1":5, "key2":2}, {"key1":5, "key2":1}]
sorted_list = sorted(unsorted_list, key=lambda k: k["key2"])
Example 2: sort list of dictionaries python by value
newlist = sorted(list_to_be_sorted, key=lambda k: k['name'])