Skip to content

Instantly share code, notes, and snippets.

@wethinkagile
Created May 30, 2014 14:44
Show Gist options
  • Save wethinkagile/426f1a39db33713628f4 to your computer and use it in GitHub Desktop.
Save wethinkagile/426f1a39db33713628f4 to your computer and use it in GitHub Desktop.
def insertionSort(aList):
# starting from 1 because n-1
for index in range(1,len(aList):
currentValue = aList[index]
position = index
while position > 0 and aList[position-1] > currentValue:
aList[position] = aList[position-1]
position = position-1
aList[position] = currentValue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment