Skip to content

Instantly share code, notes, and snippets.

@abusque
Created April 5, 2015 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abusque/7202d830764eba6523de to your computer and use it in GitHub Desktop.
Save abusque/7202d830764eba6523de to your computer and use it in GitHub Desktop.
This is an "aired-out" version of Mark Sheppard's 145 bytes quicksort
/*
* This is an "aired-out" version of Mark Sheppard's
* 145 bytes quicksort, also found on GitHub Gist:
* https://gist.github.com/marksheppard/31cd41b527efe1187983
*/
s(*l, n)
{
int i, j;
if(n > 1) {
for(i = -1, j = n;; ++i, --j) {
while(l[++i] < l[1]);
while(l[1] < l[--j]);
if(i >= j) break;
l[j] += l[i] - (l[i] = l[j]);
};
s(l, i);
s(l + i, n - i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment