📜  python 按自定义函数对二维数组进行排序 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:33.715000             🧑  作者: Mango

代码示例1
>>> a = [
     [12, 18, 6, 3], 
     [ 4,  3, 1, 2], 
     [15,  8, 9, 6]
]
>>> a.sort(key=lambda x: x[1])
>>> a
[[4,  3,  1, 2], 
 [15, 8,  9, 6], 
 [12, 18, 6, 3]]