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