Sorting algorithms in Ruby