Skip to content

Instantly share code, notes, and snippets.

@junjihashimoto
Created October 10, 2013 13:31
Show Gist options
  • Save junjihashimoto/6918343 to your computer and use it in GitHub Desktop.
Save junjihashimoto/6918343 to your computer and use it in GitHub Desktop.
short quicksort
void sort(int* v,int l){
if(l<=1) return;
int d[l],b=0,e=l;
memcpy(d,v,l*sizeof(int));
for(int i=l-1;i>=0;i--)
if(d[i]<=d[0]) v[b++]=d[i];
else v[--e]=d[i];
sort(v,b-1); sort(v+b,l-e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment