The mere sort algorithm was inspired by this example.
pseudo code
split each element into partitions of size 1
recursively merge adjacent partitions
for i = leftPartIdx to rightPartIdx
if leftPartHeadValue <= rightPartHeadValue
copy leftPartHeadValue
else: copy rightPartHeadValue; Increase InvIdx
copy elements back to original array
Merge takes two slice of ints (assuming they are sorted) and merges them
into a single slice. If the the inputs are sorted, the resulting merge will
preserve the correct sorted order.
If the slices are not sorted the resulting slice will have unpredictable
results.
MergeSort takes the provided data (slice of int) and applies the merge sort algorithm, to sort the data.
The runtime of merge sort is at best, at worst, and at average always O(n * logn).