Merge sort is a divide-and-conquer, stable sort that runs in guaranteed O(n log n) time. It splits the array in half, sorts each half recursively, then merges the two sorted halves.
The idea
A single element is already sorted (base case). Merging two sorted lists is linear, and we do log n levels of merging.
