Created
February 15, 2013 22:00
-
-
Save asayers/4963897 to your computer and use it in GitHub Desktop.
Accepts a dict and returns a list of the keys, ordered according to their values.
This file contains hidden or 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 rank(hash): | |
ranking = [] | |
for v in set(sorted(hash.itervalues())): | |
ranking.extend([key for key, val in hash.items() if val == v]) | |
return ranking |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment