One line sorting

Your sort method isn't really what most people would consider functional
programming, being that it relies on mutating the array (and the
each-method
which isn't even present in purely functional languages being that it
needs
side-effects to have any effect at all).

Ok, but it does look elegant and in one line.
That's how programs should look.
'The 'each' method can give me index of an element. I would use 'map'
instead
but it can't give me index, just the element so I would have to create a new
list.
I guess that would be pure functional and maybe more efficient in this
case..
What are side-effects in this case ?

If you want to implement a sort method in functional style, you should
consider doing a recursive quick sort, which is quite simple and can be
done
in one line if you don't count the "def foo()" and "end" as their own
lines.
Also functional programming does not equal "one line". There's nothing
wrong
with spreading it out over multiple lines for readability.

Just what I was going to try next.

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!