跳转至主要内容

C'est La Vie

Python中,对列表的排序

hliang
最后编辑于 2010年10月22日
diguList = [(4, 'john'), (7, 'steve'), (2, 'alice')]
sorted(diguList, key=lambda diguId:diguId[0], reverse=True)
# 结果:diguList = [(7, 'steve'), (4, 'john'), (2, 'alice')]

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注