dictionary order python code example
Example 1: sort the dictionary in python
d = {2: 3, 1: 89, 4: 5, 3: 0}
od = sorted(d.items())
print(od)
Example 2: sort a dictionary
from operator import itemgetter
new_dict = sorted(data.items(), key=itemgetter(1))