Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Non-destructive Quicksort.
- def quicksort(list)
- return list if list.size <= 1
- left, right = list.partition { |e| e < list.first }
- pivot = right.shift
- quicksort(left) + [pivot] + quicksort(right)
- end
Add Comment
Please, Sign In to add comment