Created
August 22, 2017 07:39
-
-
Save jss367/f1c7c82a980660df29513ba35eda22f7 to your computer and use it in GitHub Desktop.
Sort dictionary by count of values
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
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