Reputation: 33263
I have a 3 dimensional dictionary
d = ({k1:{k2:{k3:v}}}
and many more such keys....)
Now, I want to sort this dictionary by k3? What is the best way to do this?
Upvotes: 0
Views: 186
Reputation: 113998
sorted_keys = sorted(d.keys(),key=lambda x:d[x]['key2']['key3'])
will sort the keys for you ... (since dictionaries are by definition unsorted)
Upvotes: 3