Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # colins Bubble sort
- my_list = [3,6,8,1,4,6,9,2,6,0,-3]
- def bubblesort(unsorted):
- my_sorted_list = my_list[:]
- swapped = True
- while swapped:
- swapped = False
- for i in range(len(my_sorted_list)-1):
- if my_sorted_list[i] > my_sorted_list[i+1]:
- my_sorted_list[i], my_sorted_list[i+1] = my_sorted_list[i +1], my_sorted_list[i]
- swapped = True
- print(my_sorted_list)
- print(my_list)
- #print(my_sorted_list)
- bubblesort(my_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement