Update sort_dict_by_value.md

This commit is contained in:
Isabelle Viktoria Maciohsek
2021-01-08 00:56:50 +02:00
committed by GitHub
parent 6169dda836
commit b202f2f433

View File

@ -3,7 +3,7 @@ title: sort_dict_by_value
tags: dictionary,intermediate tags: dictionary,intermediate
--- ---
Sorts the given dictionary by key. Sorts the given dictionary by value.
- Use `dict.items()` to get a list of tuple pairs from `d` and sort it using a lambda function and `sorted()`. - Use `dict.items()` to get a list of tuple pairs from `d` and sort it using a lambda function and `sorted()`.
- Use `dict()` to convert the sorted list back to a dictionary. - Use `dict()` to convert the sorted list back to a dictionary.