标签:ever iter python lam python 字典 sorted tor port 数据结构
x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0}
sorted = sorted(x.iteritems(), key=lambda x: x[1], reverse=True)
import operator;sorted = sorted(x.iteritems(), key=operator.itemgetter(1), reverse=True)
x = [(0, 0), (2, 1), (1, 2), (4, 3), (3, 4)]
sorted = sorted(x.iteritems(), key=lambda x: x[1], reverse=True)
import operator;sorted = sorted(x.iteritems(), key=operator.itemgetter(1), reverse=True)
x = [{‘name‘: ‘Homer‘, ‘age‘: 39}, {‘name‘: ‘Bart‘, ‘age‘: 10}]
sorted = sorted(x, key=operator.itemgetter(‘name‘))
参考文献:
https://blog.csdn.net/xiaoQL520/article/details/78134260
标签:ever iter python lam python 字典 sorted tor port 数据结构
原文地址:https://www.cnblogs.com/jhc888007/p/9202872.html