Rank the indexes of a list in Python 3

-1

For example I have a list

[6,4,3,9,1]

The answer to this would be the index of the highest value of this list in order of example for the list above

[1,3,2,0,4]

These are the indexes of the places where their indexes are, so I've done so far:

def Cria_listas(tl,tv):
    valor = []
    if tv >= 1:
       for i in range(tl):
          valor = valor + [random.randint(0,tv]
       print(valor)
       return Fromint(valor)

def Fromint(n):
   indice = []
   for i in range(len(n)):
      indice = [n.index(max(n))] + indice

Cria_listas(5,99)

I can find the highest value index, but how do I find the next

    
asked by anonymous 01.09.2018 / 23:25

1 answer

0
lista = [6,4,3,9,1]

#lista com os valores em ordem decrescentes e sem valores repetidos
lista_decrescente = list(set(lista))
lista_decrescente.sort(reverse=True)

lista_indicies = [None]*len(lista)

indicie = 0
for num in lista_decrescente:
    for i in range(0, len(lista)):
        if lista[i] == num:
            lista_indicies[i] = indicie
            indicie += 1

>>> print(lista_indicies)
[1, 2, 3, 0, 4]
    
02.09.2018 / 03:05