One line sorting

Ok, but it does look elegant and in one line.
That’s how programs should look.

I beg to disagree… That’s definitely not what MY programs look like
and they hopefully never will. Just because it’s in one line, it’s not
good.
Readability is a big issue when developing “good” software.
After all, you want to be able to understand what you did, even
some months or years after you wrote the code. Putting everything
in one line doesn’t help there very much in my experience.

Greetz!

On Jul 13, 5:47 am, “Haris Bogdanoviæ” [email protected] wrote:

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})