可能重複:
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)
,但它不起作用。
怎麼辦?