print("\tInsertion Sort (Ordenação de lista)\n")

def insertion_sort(lista):

    iteracoes = len(lista)
    for i in range(1, iteracoes):
        j = i - 1
        chave = lista[i]

        while j >= 0 and lista[j] > chave:
            lista[j + 1] = lista[j]
            j -= 1
        lista[j + 1] = chave

    return lista

lista_desordenada = [45, 10, 2, 27, 9, 5, 11, 100, 90]
lista_ordenada = insertion_sort(lista_desordenada)
print(lista_ordenada)












Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: