Created
October 26, 2014 09:37
-
-
Save koehlma/1e6011df8f03ecc20fa4 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 insertionsort(liste): | |
counter = 0 | |
for i in range(1, len(liste)): | |
x, j = liste[i], i | |
while j > 0: | |
counter += 1 | |
if not liste[j - 1] > x: break | |
liste[j] = liste[j - 1] | |
j -= 1 | |
liste[j] = x | |
return counter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment