Created
March 10, 2018 19:14
-
-
Save wilcoln/e98edd9160eecd0b6c60125ae35b758f to your computer and use it in GitHub Desktop.
Python Insertion sort code
This file contains 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(array): | |
for i in range(1, len(array)): | |
key = array[i] | |
j = i-1 | |
while(j>-1 and array[j] > key): | |
array[j+1] = array[j] | |
j-=1 | |
array[j+1] = key |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment