Skip to content

Instantly share code, notes, and snippets.

@zallarak
Created January 8, 2012 17:35
Show Gist options
  • Save zallarak/1579087 to your computer and use it in GitHub Desktop.
Save zallarak/1579087 to your computer and use it in GitHub Desktop.
Insertion Sort
def InsertionSort(A):
"""
Takes a list, returns a list.
"""
for j in range(len(A)):
key = A[j]
i = j-1
while (i>=0) and (A[i]>key):
A[i+1] = A[i]
i = i-1
A[i+1] = key
return A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment