Skip to content

Instantly share code, notes, and snippets.

@anapaulagomes
Created April 7, 2019 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anapaulagomes/28fa022a85f7c1d63a8257ca5bedf200 to your computer and use it in GitHub Desktop.
Save anapaulagomes/28fa022a85f7c1d63a8257ca5bedf200 to your computer and use it in GitHub Desktop.
Order a dict by value
# stolen from https://stackoverflow.com/questions/20944483/python-3-sort-a-dict-by-its-values
[(k, d[k]) for k in sorted(d, key=d.get, reverse=True)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment