threeway merge sort algorithm