Python: Sort a dictionary by value
- by the empirical programmer
I have a dictionary of values read from 2 fields in a database: a string field and a numeric field. The string field is unique so that is the key of the dictionary.
I can sort on the keys, but how can I sort based on the values?
Note: I have read this post 72899 and probably could change my code to have a list of dictionaries but since I do not really need a list of dictionaries I wanted to know if there a simpler solution.