Tom_Jung

Untitled

Feb 3rd, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. numbers = [11, 10, 7, 20, 6, 18, 14, 12, 14, 19, 11]
  2.  
  3. print("Numbers =", numbers)
  4.  
  5. def bubble_sort(list):
  6. sorted = list[:]
  7. sort = True
  8. while sort == True:
  9. sort = False
  10. for i in range(len(sorted)-1):
  11. if sorted[i] > sorted[i+1]:
  12. sorted[i], sorted[i+1] = sorted[i+1], sorted[i]
  13. sort = True
  14.  
  15. print("Sorted = ", sorted)
  16.  
  17. bubble_sort(numbers)
Advertisement
Add Comment
Please, Sign In to add comment