Skip to content

Instantly share code, notes, and snippets.

@hkdobrev
Created February 6, 2013 23:21
Show Gist options
  • Save hkdobrev/4726813 to your computer and use it in GitHub Desktop.
Save hkdobrev/4726813 to your computer and use it in GitHub Desktop.
Insertion sort modified from http://www.youtube.com/watch?v=lEA31vHiry4
def insertion_sort(list):
for index in range(len(list))
value = list[index]
i = index - 1
while i>=0 and value < list[i]:
list[i+1] = list[i] # shift number in slot i right to slot i+1
list[i] = value #shift value left into slot i
i = i - 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment