How to sort multidimensional array by column?

前端 未结 6 1473
不思量自难忘°
不思量自难忘° 2020-12-02 20:00

Is there a way to use the sort() method or any other method to sort a list by column? Lets say I have the list:

[
[John,2],
[Jim,9],
[Jason,1]
]
6条回答
  •  情深已故
    2020-12-02 20:44

    below solution worked for me in case of required number is float. Solution:

    table=sorted(table,key=lambda x: float(x[5]))
    for row in table[:]:
        Ntable.add_row(row)
    

    '

提交回复
热议问题