原链接:How to sort a list of lists by a specific index of the inner list?
from operator import itemgetter #排序前 L = [[1,1.0345],[2,6.098],[3,4.89],[2,5.97]] #采用itemgetter方法,支持多列排序,示例代码同时排列0,1两列 sorted(L, key=itemgetter(0,1)) #输出结果: #[[1, 1.0345], [2, 5.97], [2, 6.098], [3, 4.89]]
文章的脚注信息由WordPress的wp-posturl插件自动生成