Issue
I have a dict {'a': 2, 'b': 0, 'c': 1}
.
Need to sort keys by values so that I can get a list ['b', 'c', 'a']
Is there any easy way to do this?
Solution
sorted_keys = sorted(my_dict, key=my_dict.get)
Answered By - georg
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.