def quick_sort list
(x = list.pop) ? quick_sort(list.select {|i| i <= x}) + [x] + quick_sort(list.select {|i| i > x}) : []
end
好吧,有点儿慢....
qs([]) ->
[];
qs([H|T]) ->
qs([E || E <- T, E <= H]) ++ [H] ++ qs([E || E <- T, E > H]).
#8 楼 @blacktulip 用了就是这样:
def qs x, *xs
l, r = xs.partition {|e| e <= x }
x ? [*qs(l), x, *qs(r)] : []
end