Created
February 6, 2013 23:21
-
-
Save hkdobrev/4726813 to your computer and use it in GitHub Desktop.
Insertion sort modified from http://www.youtube.com/watch?v=lEA31vHiry4
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(list): | |
for index in range(len(list)) | |
value = list[index] | |
i = index - 1 | |
while i>=0 and value < list[i]: | |
list[i+1] = list[i] # shift number in slot i right to slot i+1 | |
list[i] = value #shift value left into slot i | |
i = i - 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment