python字典按照value进行排序

d = {'a':1,'b':4,'c':2}
print(sorted(d.items(),key = lambda x:x[1],reverse = True))

 输出

[('b', 4), ('c', 2), ('a', 1)]
原文地址:https://www.cnblogs.com/sea-stream/p/10201286.html