class Array
def quick_sort
h, *t = self
h ? t.partition {|e| e < h}.inject {|l, r| l.quick_sort + [h] + r.quick_sort} : []
end
end
class Array
def quick_sort
h, *t = self
h ? t.partition {|e| e < h}.inject {|l, r| l.quick_sort + [h] + r.quick_sort} : []
end
end
Comments