Last active
August 29, 2015 14:03
-
-
Save edap/cc4933a180e094aaf628 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Quick sort algorithm with random pivot and recursion