Skip to content

Instantly share code, notes, and snippets.

@dcolish
Created April 16, 2012 04:53
Show Gist options
  • Save dcolish/2396383 to your computer and use it in GitHub Desktop.
Save dcolish/2396383 to your computer and use it in GitHub Desktop.
import random
def insert_sort(l):
for i, item in enumerate(l):
while i > 0 and l[i - 1] > item:
l[i] = l[i - 1]
i -= 1
l[i] = item
things = range(10)
random.shuffle(things)
print things
insert_sort(things)
print things
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment