Repository where I mostly put random python scripts.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
351 B

  1. # coding: utf-8
  2. # In[43]:
  3. alist = [54,26,93,17,77,31,44,55,20]
  4. def bubbleSort(alist):
  5. for passnum in range(len(alist)-1,0,-1):
  6. for i in range(passnum):
  7. if alist[i]>alist[i+1]:
  8. temp = alist[i]
  9. alist[i] = alist[i+1]
  10. alist[i+1] = temp
  11. return alist
  12. print(bubbleSort(alist))