按值对枚举列表进行排序

Eul*_*ter 2 python list enumerate

MWE:

list1 = [2,5,46,23,9,78]
list1 = list(enumerate(list1))
Run Code Online (Sandbox Code Playgroud)

现在假设我想通过索引1对该列表进行排序,即按原始列表1排序,例如按升序排序.我怎么做?

我想要一些可以给我索引和值的东西.

list2 = sorted(list1[1], key=float)
Run Code Online (Sandbox Code Playgroud)

Uri*_*iel 7

item[1]按键排序:

>>> list2 = sorted(list1, key=lambda x:x[1])
>>> list2
[(0, 2), (1, 5), (4, 9), (3, 23), (2, 46), (5, 78)]
Run Code Online (Sandbox Code Playgroud)