Skip to content

Instantly share code, notes, and snippets.

@ukstudio
Created January 16, 2009 03: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 ukstudio/47788 to your computer and use it in GitHub Desktop.
Save ukstudio/47788 to your computer and use it in GitHub Desktop.
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