asda

Plain text code posted by asda
created at 21 Nov 08:27, updated at 21 Nov 10:06

Edit | Back
1
2
3
4
5
6
7
8
class Array
  def quick_sort
    return self if length <= 1
    pivot = self[0]
    less, greatereq = self[1..-1].partition { |x| x < pivot} 
    less.quick_sort + [pivot] + greatereq.quick_sort
  end
end
213 Bytes in 1 ms with coderay