moved all Python sorting algorithms into 1 folder

This commit is contained in:
Joe James
2018-06-29 16:07:43 -07:00
committed by GitHub
parent fe3e849350
commit c78e569ceb
6 changed files with 556 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
#---------------------------------------
# Selection Sort
#---------------------------------------
def selection_sort(A):
for i in range (0, len(A) - 1):
minIndex = i
for j in range (i+1, len(A)):
if A[j] < A[minIndex]:
minIndex = j
if minIndex != i:
A[i], A[minIndex] = A[minIndex], A[i]
A = [5,9,1,2,4,8,6,3,7]
print(A)
selection_sort(A)
print(A)