python 字典 2017-04-20 按字典值大小进行排序# How to sort a Python dict by value# (== get a representation sorted by value)>>> xs = {'a': 4, 'b': 3, 'c': 2, 'd': 1}>>> sorted(xs.items(), key=lambda x: x[1])[('d', 1), ('c', 2), ('b', 3), ('a', 4)]# Or:>>> import operator>>> sorted(xs.items(), key=operator.itemgetter(1))[('d', 1), ('c', 2), ('b', 3), ('a', 4)] 最后更新时间:2023-12-11 15:18:57 http://zhourudong.cn/2017/04/20/37-python-字典/ 赏 Prev django orm Next ActiveMQ_zookeeper高可用配置