przykladowe-projekty/Bubble sort

24 lines
442 B
Plaintext

lstlen = int(input())
lst = [int(x) for x in input().split()]
nr = True
x = 0
while True:
while x < ((lstlen) - 1):
if lst[x] > lst[x + 1]:
a, b = lst[x], lst[x + 1]
lst[x], lst[x+1] = b, a
x += 1
nr = False
else:
x += 1
if nr:
break
else:
lstlen -= 1
nr = True
x = 0
for j in range(len(lst)):
print(lst[j],end=" ")