0

Python indexing

I want to sort the array and get the Index of the elements from its original array , I couldn't think of any logic but I have tried something. https://code.sololearn.com/ckD70K4SE25f/?ref=app

13th Apr 2019, 12:48 PM
Mallika Das
Mallika Das - avatar
5 Respuestas
+ 4
Loniie and it's working! I thought of using for loop and then storing index of each item(from smt) in mt to a list but since the list mt list has repeated elements, it always gives the index of first occurrence and hence not a good one.
13th Apr 2019, 1:28 PM
Шащи Ранжан
Шащи Ранжан - avatar
+ 2
print(sorted(enumerate(mt), key=lambda x:x[1])[::-1])
13th Apr 2019, 2:00 PM
Diego
Diego - avatar
+ 1
https://code.sololearn.com/ct4Mf17IDc1S/?ref=app Diego here in the example the order of first two elements must be 9 and 11. Same for 56
13th Apr 2019, 3:01 PM
Mallika Das
Mallika Das - avatar
+ 1
Thanks Anna
13th Apr 2019, 5:35 PM
Mallika Das
Mallika Das - avatar