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