I have a dictionary like this.
d = {'"mn': '800"', '"kl': '700"', '"ng': '1100"'}
How to sort this into descending order. like below
ng,1100
mn,800
kl,700
I have a dictionary like this.
d = {'"mn': '800"', '"kl': '700"', '"ng': '1100"'}
How to sort this into descending order. like below
ng,1100
mn,800
kl,700
You can user OrderedDict for that.
reverse_dictionary = OrderedDict(reversed(sorted(d.items())), key=lambda t: t[1])
Im not sure what you mean, a dictionary by definition is unsorted. you may want to use an array of dictionaries.