怎么给字典排序后,还是这普通的字典
a_dic = {'a':{'val':3}, 'b':{'val':4}, 'c':{'val':1}} dict= sorted(a_dic.iteritems(), key=lambda d:d[1]['val'], reverse = True) print(dict)
运行结果:
[('b', {'val': 4}), ('a', {'val': 3}), ('c', {'val': 1})]