内部带有列表的Python排序列表

内部带有列表的Python排序列表,python,list,sorting,python-2.7,Python,List,Sorting,Python 2.7,假设一个列表列表,如下所示: lists=[[3,2,1,4],[6,4,2,8],[9,6,3,12]] lists=[[1,2,3,4],[2,4,6,8],[3,6,9,12]] #can be another variable lists = [[] for x in xrange(n)] 如果我想按列表[0]排序,它应该按如下方式排序: lists=[[3,2,1,4],[6,4,2,8],[9,6,3,12]] lists=[[1,2,3,4],[2,4,6,8],[3,6,

假设一个列表列表,如下所示:

lists=[[3,2,1,4],[6,4,2,8],[9,6,3,12]]
lists=[[1,2,3,4],[2,4,6,8],[3,6,9,12]] #can be another variable
lists = [[] for x in xrange(n)]
如果我想按
列表[0]
排序,它应该按如下方式排序:

lists=[[3,2,1,4],[6,4,2,8],[9,6,3,12]]
lists=[[1,2,3,4],[2,4,6,8],[3,6,9,12]] #can be another variable
lists = [[] for x in xrange(n)]
有三个列表的列表:

list1,list2,list3=(list(t) for t in zip(*sorted(zip(lists[0], lists[1],lists[2]))))
但这是一个特定的解决方案,列表中的n个列表可能更一般。
列表
变量是这样创建的:

lists=[[3,2,1,4],[6,4,2,8],[9,6,3,12]]
lists=[[1,2,3,4],[2,4,6,8],[3,6,9,12]] #can be another variable
lists = [[] for x in xrange(n)]
并将这些值附加到

实际上,所有的值都是数值(float或int),但这可以更好地解释它

lists=[[3,2,1,4],["three","two","one","four"],["tres","dos","uno","cuatro"]]
我想知道如何对其进行排序,并最终得出以下结论:

[[1,2,3,4],["one","two","three","four"],["uno","dos","tres","cuatro"]]

这可能是不太可能的情况,最好使用Schwartzian变换

>>> lists=[[3,2,1,4],["three","two","one","four"],["tres","dos","uno","cuatro"]]
>>> [[x for i, x in sorted(zip(lists[0], sublist))] for sublist in lists]
[[1, 2, 3, 4], ['one', 'two', 'three', 'four'], ['uno', 'dos', 'tres', 'cuatro']]

这可能是不太可能的情况,最好使用Schwartzian变换

>>> lists=[[3,2,1,4],["three","two","one","four"],["tres","dos","uno","cuatro"]]
>>> [[x for i, x in sorted(zip(lists[0], sublist))] for sublist in lists]
[[1, 2, 3, 4], ['one', 'two', 'three', 'four'], ['uno', 'dos', 'tres', 'cuatro']]

在列表上使用
*
符号:
zip(*列表)
。在列表上使用
*
符号:
zip(*列表)
。谢谢这正是我想要的。谢谢这正是我想要的。