Sorting based on a dictionary value or key is easy using Python. Sort by value in a dictionary In Python 3.7 and above, a combination of dictionary comprehension and sorted can be used: 1foo = {"first": 1, "third": 3, "second": 2, "zeroth": 0} 2print({k: v for k, v in sorted(foo.items(), key=lambda i: i[1])})In addition, 1foo = {"first": 1, "third": 3, "second": 2, "zeroth": 0} 2print(dict(sorted(foo.items(), key=lambda i: i[1])))Output: 1{'zeroth': 0, 'first': 1, 'second': 2, 'third': 3}sort...