Ruby version of merge-sort