custom mergesort