K
klochner
def quick_sort(array)
return array if array.length <=1
pivot=array[array.length/2]
return quick_sort(array.select {|i| i<pivot}) + array.select {|i|
i==pivot} + quick_sort(array.select {|i| i>pivot})
end
Why not use:
quick_sort(array.select {|i| i<=pivot}) + quick_sort(array.select {|i|
i>pivot})