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.

21 lines
461 B

  1. # coding: utf-8
  2. # In[50]:
  3. alist = [54,26,93,17,77,31,44,55,20]
  4. def selectionSort(alist):
  5. for fillslot in range(len(alist)-1,0,-1):
  6. positionOfMax=0
  7. for location in range(1,fillslot+1):
  8. if alist[location]>alist[positionOfMax]:
  9. positionOfMax = location
  10. temp = alist[fillslot]
  11. alist[fillslot] = alist[positionOfMax]
  12. alist[positionOfMax] = temp
  13. return alist
  14. print(shortBubbleSort(alist))