A re-implementation of Boost.Sort's SpinSort. Checks for sorted or fully reversed input in O(n), then splits into two halves, sorts the left via ping-pong merge into a half-buffer, sorts the right in-place using the freed left space as scratch, and merges with a half-merge.
Uses only ceil(n/2) auxiliary memory while maintaining stability. Achieves O(n) on sorted, reversed, or nearly-sorted input. For large ranges (over 1024 elements), CheckStableSort detects a sorted prefix with a small unsorted tail and handles it via partial insertion.