Skip to content

Instantly share code, notes, and snippets.

@mikezink
Created September 5, 2019 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mikezink/ee06ef6faed5cf75a7be8300cebf2cd1 to your computer and use it in GitHub Desktop.
Save mikezink/ee06ef6faed5cf75a7be8300cebf2cd1 to your computer and use it in GitHub Desktop.
def insertionSort(alist):
for index in range(1,len(alist)):
currentvalue = alist[index]
position = index
while position>0 and alist[position-1]>currentvalue:
alist[position]=alist[position-1]
position = position-1
alist[position]=currentvalue
alist = [54,26,93,17,77,31,44,55,20]
insertionSort(alist)
print(alist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment