如何基于嵌套字典的内部值排序Python字典?基于嵌套字典值排序Python字典
例如,整理以下mydict
基础上context
值:
mydict = {
'age': {'context': 2},
'address': {'context': 4},
'name': {'context': 1}
}
结果应该是这样的:
{
'name': {'context': 1},
'age': {'context': 2},
'address': {'context': 4}
}
你想要一个列表输出吗?或字典输出? – Deniz 2012-08-01 06:34:16