Sort an enumerated list by the value

Viewed 11147

MWE:

list1 = [2,5,46,23,9,78]
list1 = list(enumerate(list1))

Now suppose I want to sort this list by the index 1, i.e. by the original list1, in say, ascending order. How do I do that?

I would like something that could then give me both the indexes and the values.

list2 = sorted(list1[1], key=float)
3 Answers
Related