Skip to content

Commit

Permalink
Update sort_dict_by_value.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinityyi authored Jan 7, 2021
1 parent 6169dda commit b202f2f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion snippets/sort_dict_by_value.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: sort_dict_by_value
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()` to convert the sorted list back to a dictionary.
Expand Down

0 comments on commit b202f2f

Please sign in to comment.