Created
November 28, 2010 23:24
-
-
Save pyropeter/719391 to your computer and use it in GitHub Desktop.
Forbidden implementation of an insertion sort
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
float sorted[histLength]; | |
sorted[0] = history[0]; | |
for (int i = 1 ; i < histLength ; i++) { | |
for (int j = 0 ; j < i ; j++) { | |
if (history[i] < sorted[j]) { | |
for (int k = i - 1 ; k >= j ; k--) | |
sorted[k+1] = sorted[k]; | |
sorted[j] = history[i]; | |
goto foo; | |
} | |
} | |
sorted[i] = history[i]; | |
foo:; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment