material/Beiträge/DDI-Vortrag 2/Source/sources/bubblesort.py

8 lines
No EOL
256 B
Python

def BubbleSort(lst):
for passesLeft in range(len(lst)-1, 0, -1):
for i in range(passesLeft):
if lst[i] > lst[i + 1]:
lst[i], lst[i + 1] = lst[i + 1], lst[i]
return lst
print BubbleSort([7,9,1,2,3,6,4,5,8,0]);