Sep-21-2022, 09:19 AM
Given a list:
It's a shame I cannot use dict or set to help with this problem. No libraries import either sadly.
lst = [48,52,35,35,44,35]I want to sort the list in descending order, so I use this:
sortedlst = sorted(slst, reverse = True)I also want the original index in a sorted position as well. Like this:
sortedlstindx = [1,0,4,2,3,5]for that I use this code:
sortedindx = [elem.index(lst) for elem in sorted(lst, reverse = True)]The result I got is this:
sortedindx = [1,0,4,2,2,2]How can I modify the code to give the result I want?
It's a shame I cannot use dict or set to help with this problem. No libraries import either sadly.