Skip to content

Instantly share code, notes, and snippets.

@O-I
Last active December 25, 2015 22:19
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 O-I/7048779 to your computer and use it in GitHub Desktop.
Save O-I/7048779 to your computer and use it in GitHub Desktop.
Ruby Quicksort
def quicksort(list)
return list if list.length < 2
pivot = list.shift
left, right = list.partition { |el| el < pivot }
quicksort(left) + [pivot] + quicksort(right)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment