Browse Source

Merge pull request #2 from sunny3p/sortalgos

Sortalgos
pull/4/head
Sunny Patel 6 years ago
committed by GitHub
parent
commit
71b0be217c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 0 deletions
  1. +21
    -0
      sorting/selectionSort.py

+ 21
- 0
sorting/selectionSort.py View File

@ -0,0 +1,21 @@
# coding: utf-8
# In[50]:
alist = [54,26,93,17,77,31,44,55,20]
def selectionSort(alist):
for fillslot in range(len(alist)-1,0,-1):
positionOfMax=0
for location in range(1,fillslot+1):
if alist[location]>alist[positionOfMax]:
positionOfMax = location
temp = alist[fillslot]
alist[fillslot] = alist[positionOfMax]
alist[positionOfMax] = temp
return alist
print(selectionSort(alist))

Loading…
Cancel
Save