Sort dictionary by value
Sorts the given dictionary by value.
- Use
dict.items()
to get a list of tuple pairs fromd
and sort it using a lambda function andsorted()
. - Use
dict()
to convert the sorted list back to a dictionary. - Use the
reverse
parameter insorted()
to sort the dictionary in reverse order, based on the second argument. - ⚠️ NOTICE: Dictionary values must be of the same type.