Clean up merge sort and add comparator function.