Skip to content

Instantly share code, notes, and snippets.

@Rynaro
Last active August 29, 2015 13:57
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 Rynaro/9809146 to your computer and use it in GitHub Desktop.
Save Rynaro/9809146 to your computer and use it in GitHub Desktop.
Simple QuickSort in Ruby
def quick ary
(x = ary.pop)? quick( ary.select do |i| i < x end) + [x] + quick( ary.select do |i| i > x end ) : []
end
print quick [23, 56, 87, 1, 5, 67, 345, 76, 5, 8, 7, 234]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment