25 Algorithms library [algorithms]

25.4 Sorting and related operations [alg.sorting]

25.4.1 Sorting [alg.sort]

25.4.1.2 stable_sort [stable.sort]

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

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

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

Complexity: It does at most N log2(N) (where N == last - first) comparisons; if enough extra memory is available, it is N log(N).

Remarks: Stable ([algorithm.stable]).