Created
May 30, 2014 03:23
-
-
Save wethinkagile/4a2040b8e3e7501d5215 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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