Created
July 3, 2018 11:30
-
-
Save erika-dike/3addfc1fec3e9cceff14273bb9f4b2ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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