python sort the values in a dictionaryi

from operator import itemgetter
new_dict = sorted(data.items(), key=itemgetter(1))

Here is what the above code is Doing:
1. We use the sorted function to sort the dictionary by value.
2. We pass in the dictionary to be sorted.
3. We pass in the key argument, which is a function that returns the value to sort on.
4. We use the operator module’s itemgetter function to return the value.