Merge sort algorithm implementation.