Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my_list = [5,9,5,8,1,3]
- def bubble_sort(unsorted):
- list_copy = unsorted
- swapped = True
- while swapped == True:
- swapped = False
- for index in range(0, len(list_copy) -1):
- if list_copy[index] > list_copy[index + 1]:
- list_copy[index], list_copy[index + 1] = list_copy[index + 1], list_copy[index]
- swapped = True
- return list_copy
- print(bubble_sort(my_list))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement