Merge sort solution