A re-implementation of LLVM libc++'s std::stable_sort: allocates an O(n) auxiliary buffer upfront, then recursively sorts both halves via ping-pong merging, alternating which buffer is the source and which is the destination at each recursion level. Falls back to Insertion sort for small sub-arrays.
The ping-pong strategy eliminates the copy-back step of standard Merge sort, each recursion level writes directly from one buffer to the other, so the sorted result always surfaces in the original array with no extra pass. Stability is guaranteed because merges always prefer the left half on equal elements.