I have a simple list of values of which I need the index sorted by the original value order (max to min).
Let's assume the list is
maxList = [7, 3, 6, 9, 1, 3]
The result should be:
indexedMaxList = [3, 0, 2, 1, 5, 4]
What I tried so far:
def ClusteringOrder(maxList):
sortedMaxList = maxList.copy()
sortedMaxList.sort(reverse=True)
indexedMaxList = []
for i in range(len(maxList)):
indexedMaxList.append(maxList.index(sortedMaxList[i]))
return(indexedmaxList)
Problem is obviously, doing it this way returns the index of the first occurrence of duplicate values. In this case, the double 3 will return a 1 two times, hence the result will be:
indexedMaxList = [3, 0, 2, 1, 1, 4]
Is there any simple way of doing this to get the actual positions back?