ruby implementation of mergesort