Skip to content

Instantly share code, notes, and snippets.

@pyropeter
Created November 28, 2010 23:24
Show Gist options
  • Save pyropeter/719391 to your computer and use it in GitHub Desktop.
Save pyropeter/719391 to your computer and use it in GitHub Desktop.
Forbidden implementation of an insertion sort
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