Skip to content

Instantly share code, notes, and snippets.

@erika-dike
Created July 3, 2018 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erika-dike/3addfc1fec3e9cceff14273bb9f4b2ae to your computer and use it in GitHub Desktop.
Save erika-dike/3addfc1fec3e9cceff14273bb9f4b2ae to your computer and use it in GitHub Desktop.
def insertion_sort(alist):
marker = 1
while marker < len(alist):
current = alist[marker]
second_marker = marker - 1
while current < alist[second_marker] and second_marker >= 0:
alist[second_marker + 1] = alist[second_marker]
second_marker -= 1
alist[second_marker + 1] = current
marker += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment