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