Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def bubble_sort(elements):
- swapped = True
- while swapped:
- swapped = False
- for i in range(1,len(elements)):
- if elements[i] < elements[i-1]:
- elements[i], elements[i-1] = elements[i-1], elements[i]
- swapped = True
- numbers = [5,1,4,7,2,3,8,0,6]
- bubble_sort(numbers)
- print(numbers)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement