可能重复:
Sort by key of dictionary inside a dictionary in Python排序根据自己的python值的字典
我有一本字典:
d={'abc.py':{'map':'someMap','distance':11},
'x.jpg':{'map':'aMap','distance':2},....}
现在我需要的是:我需要根据距离排序d
?我试过sorted(d.items(),key=itemgetter(1,2)
,但它不起作用。
怎么办?