Skip to content

Instantly share code, notes, and snippets.

@edap
Last active August 29, 2015 14:03
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 edap/cc4933a180e094aaf628 to your computer and use it in GitHub Desktop.
Save edap/cc4933a180e094aaf628 to your computer and use it in GitHub Desktop.
def qsort(l)
return l if l.length <= 1
pivot = l.sample
lft, rgt = l.partition {|e| e < pivot}
qsort(lft).concat(qsort(rgt))
end
@edap
Copy link
Author

edap commented Jun 29, 2014

Quick sort algorithm with random pivot and recursion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment