Created
January 16, 2009 03:03
-
-
Save ukstudio/47788 to your computer and use it in GitHub Desktop.
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
module Enumerable | |
def quicksort! | |
return self if self.size <= 1 | |
piv = self[0] | |
top, bottom = self[1..-1].partition{|i| i < piv} | |
top.quicksort + [piv] + bottom.quicksort | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment