cpp/algorithm/ranges/stable sort

Sorts the elements in the range in non-descending order. The order of equivalent elements is stable, i.e. guaranteed to be preserved.

A sequence is sorted with respect to a comparator if for any iterator  pointing to the sequence and any non-negative integer  such that  is a valid iterator pointing to an element of the sequence,  evaluates to.

@1@ Elements are compared using the given binary comparison function. @2@ Same as, but uses as the range, as if using  as  and  as.

Return value
An iterator equal to.

Complexity
comparisons, if extra memory is available; where is. comparisons otherwise. Twice as many projections as the number of comparisons in both cases.

Possible implementation
This implementation only shows the slower algorithm used when no additional memory is available. See also implementation in MSVC STL and libstdc++.