Skip to content

Instantly share code, notes, and snippets.

@daqing
Created June 7, 2009 11:03
Show Gist options
  • Select an option

  • Save daqing/125285 to your computer and use it in GitHub Desktop.

Select an option

Save daqing/125285 to your computer and use it in GitHub Desktop.
def insertion_sort(seq):
for i in range(1, len(seq)):
key = seq[i];
left = i - 1;
while left >= 0 and seq[left] > key:
seq[left + 1] = seq[left]
seq[left] = key
left -= 1
return seq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment