25 Algorithms library [algorithms]

25.5 Sorting and related operations [alg.sorting]

25.5.1 Sorting [alg.sort]

25.5.1.2 stable_sort [stable.sort]

template<class RandomAccessIterator> void stable_sort(RandomAccessIterator first, RandomAccessIterator last); template<class ExecutionPolicy, class RandomAccessIterator> void stable_sort(ExecutionPolicy&& exec, RandomAccessIterator first, RandomAccessIterator last); template<class RandomAccessIterator, class Compare> void stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp); template<class ExecutionPolicy, class RandomAccessIterator, class Compare> void stable_sort(ExecutionPolicy&& exec, RandomAccessIterator first, RandomAccessIterator last, Compare comp);

Requires: RandomAccessIterator shall satisfy the requirements of ValueSwappable ([swappable.requirements]). The type of *first shall satisfy the requirements of MoveConstructible (Table [tab:moveconstructible]) and of MoveAssignable (Table [tab:moveassignable]).

Effects: Sorts the elements in the range [first, last).

Complexity: At most N log2(N) comparisons, where N = last - first, but only N log(N) comparisons if there is enough extra memory.

Remarks: Stable ([algorithm.stable]).