如何对列表中的列表进行排序?

siw*_*ong 0 python sorting list

我想知道如何对列表中的列表进行排序。但是,我不想按键对齐。我想按照以下方法进行更改。

arr = [[2, 3], [5, 1], [4, 1], [5, 3], [4, 2]]
# solution...
I_want_arr = [[2, 3], [1, 5], [1, 4], [3, 5], [2, 4]]
Run Code Online (Sandbox Code Playgroud)

我尝试过这个

for i in arr:
  i.sort()
Run Code Online (Sandbox Code Playgroud)

但是,它不起作用

Gab*_*bip 9

使用列表理解:

arr = [[2, 3], [5, 1], [4, 1], [5, 3], [4, 2]]
sorted_output = [sorted(l) for l in arr]
Run Code Online (Sandbox Code Playgroud)

使用map()

sorted_output = list(map(sorted, arr))
Run Code Online (Sandbox Code Playgroud)