merge sort variant