I am new to python, need an help to sort below multi-dimensional dictionary by field - "rank"
from operator import *
from collections import OrderedDict
print 'Dictionaries:'
l = {"test":{"rank":61,"test":2},"test1":{"rank":12,"test":2},"test2":{"rank":23,"test":2}}
I have tried with below approach,
d_sorted_by_value = OrderedDict(sorted(l.items(), key=attrgetter('rank')))
but getting error:
AttributeError: 'tuple' object has no attribute 'rank'