Skip to content

Instantly share code, notes, and snippets.

@alexholehouse
Created May 6, 2012 19:43
Show Gist options
  • Save alexholehouse/2624061 to your computer and use it in GitHub Desktop.
Save alexholehouse/2624061 to your computer and use it in GitHub Desktop.
Julia Quicksort algorithm
function qsort!(a,lo,hi)
i, j = lo, hi
while i < hi
pivot = a[(lo+hi)>>>1]
while i <= j
while a[i] < pivot; i = i+1; end
while a[j] > pivot; j = j-1; end
if i <= j
a[i], a[j] = a[j], a[i]
i, j = i+1, j-1
end
end
if lo < j; qsort!(a,lo,j); end
lo, j = i, hi
end
return a
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment