Created
October 8, 2016 08:13
-
-
Save hxer/98544cdb4de9d93e17d3b381a5f6d25c to your computer and use it in GitHub Desktop.
dict sort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
count = {'a': 1, 'c':4, 'g': 2} | |
sort_list = sorted(count.items(), key=lambda d: d[1], reverse=True) | |
from operator import itemgetter | |
sort_list = sorted(count.items(), key=itemgetter(1), reverse=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment