Answers for "sort a list without sort function python"

1

order a list without sort

n = int(input("Elementos da lista = "))
lista = []

for i in range(n):
    x = int(input("Valor (0 a 9) = "))
    if (i == 0) or (x > lista[- 1]):
        lista.append(x)
    else:
        pos = 0
        while (pos < len(lista)):
            if x <= lista[pos]:
                lista.insert(pos , x)
                break
            pos = pos + 1
Posted by: Guest on November-18-2020

Code answers related to "sort a list without sort function python"

Python Answers by Framework

Browse Popular Code Answers by Language