Created
April 5, 2015 16:44
-
-
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 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
/* | |
* 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