Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Implementing a Bubble Sort
- chrisList = [66,22,33,55,77,88,30,20,50,60,11,13,19]
- #sort function
- def bub_sort(aList):
- sortList = aList[:]
- changes = True
- while changes:
- changes = False
- for i in range(len(aList)-1):
- if sortList[i] > sortList[i+1]:
- sortList[i] , sortList[i+1] = sortList[i+1] , sortList[i]
- changes = True
- print(sortList)
- #output result
- print(chrisList)
- #perform the sort
- bub_sort(chrisList)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement