对列表中的多个元素进行数字排序

时间:2019-06-12 02:49:01

标签: python-3.x

根据这篇帖子How to sort a list of lists by a specific index of the inner list?的建议,我设法使用itemgetter对列表列表进行了排序

我有:

sorted2 = sorted(sorted_list, key= itemgetter(0,1))

但是看起来排序不正确

我有:

chr1 101235683 101236528
chr1 10639241 10654333
chr1 110058340 110062555

中间的条目应为第一个,因为它的长度为8位数字,其他两位为9位数字。

我基本上想在python中复制我们将在命令行中执行的操作:

sort -k1,1 -k2,2n -k3,3n

你能帮忙吗?

0 个答案:

没有答案