Answers for "python sort without aort function"

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 "python sort without aort function"

Python Answers by Framework

Browse Popular Code Answers by Language