Skip to content

Instantly share code, notes, and snippets.


richardbwest/Insertion Sort Secret

Created Nov 9, 2020
What would you like to do?
l = [7,11,3,1,2,5,6,9]
def insertion_sort(l):
for outer_index in range(1,len(l)):
current_item = l[outer_index]
inner_index = outer_index
while inner_index > 0 and l[inner_index-1] > current_item:
l[inner_index] = l[inner_index-1]
inner_index -= 1
l[inner_index] = current_item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment