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):
- swapped = True
- while swapped:
- swapped = False
- for i in range(len(unsorted)-1):
- if unsorted[i] > unsorted[i+1]:
- temp=unsorted[i]
- unsorted[i]=unsorted[i+1]
- unsorted[i+1]=temp
- swapped = True
- return unsorted
- unsorted = my_list[:]
- print("Buble list = ", unsorted)
- print("Buble ordered = ", bubble_sort(unsorted))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement