Skip to content

Instantly share code, notes, and snippets.

@jss367
Created August 22, 2017 07:39
Show Gist options
  • Save jss367/f1c7c82a980660df29513ba35eda22f7 to your computer and use it in GitHub Desktop.
Save jss367/f1c7c82a980660df29513ba35eda22f7 to your computer and use it in GitHub Desktop.
Sort dictionary by count of values
def dict_sort(dictionary, descending=False):
dict_to_list = [(dictionary[key], key) for key in dictionary]
dict_to_list.sort(descending=reverse)
return dict_to_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment