sort list without built in function python code example
Example: 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