Skip to content

Instantly share code, notes, and snippets.

@hxer
Created October 8, 2016 08:13
Show Gist options
  • Save hxer/98544cdb4de9d93e17d3b381a5f6d25c to your computer and use it in GitHub Desktop.
Save hxer/98544cdb4de9d93e17d3b381a5f6d25c to your computer and use it in GitHub Desktop.
dict sort
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