Skip to content

Instantly share code, notes, and snippets.

@wethinkagile
Created May 30, 2014 03:23
Show Gist options
  • Save wethinkagile/4a2040b8e3e7501d5215 to your computer and use it in GitHub Desktop.
Save wethinkagile/4a2040b8e3e7501d5215 to your computer and use it in GitHub Desktop.
def selectionSort(aList):
# from n-1 to 0 (excluding 0) with the stepping -1
for eachNum in range (len(aList)-1,0,-1):
positionMax = 0
for i in range(eachNum+1):
if aList[i] > aList[positionMax]:
positionMax = i
temp = aList[eachNum]
aList[eachNum] = aList[positionMax]
aList[positionMax] = temp
return aList
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment