【发布时间】:2010-07-21 11:18:03
【问题描述】:
可能重复:
Sort by key of dictionary inside a dictionary in Python
我有一本字典:
d={'abc.py':{'map':'someMap','distance':11},
'x.jpg':{'map':'aMap','distance':2},....}
现在我需要的是:我需要根据他们的距离对d进行排序?
我尝试了sorted(d.items(),key=itemgetter(1,2),但它不起作用。
怎么做?
【问题讨论】:
标签: python dictionary sorting key