25 Algorithms library [algorithms]

25.7 Sorting and related operations [alg.sorting]

25.7.1 Sorting [alg.sort]

25.7.1.1 sort [sort]

template<class RandomAccessIterator> constexpr void sort(RandomAccessIterator first, RandomAccessIterator last); template<class ExecutionPolicy, class RandomAccessIterator> void sort(ExecutionPolicy&& exec, RandomAccessIterator first, RandomAccessIterator last); template<class RandomAccessIterator, class Compare> constexpr void sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp); template<class ExecutionPolicy, class RandomAccessIterator, class Compare> void sort(ExecutionPolicy&& exec, RandomAccessIterator first, RandomAccessIterator last, Compare comp); template<RandomAccessIterator I, Sentinel<I> S, class Comp = ranges::less, class Proj = identity> requires Sortable<I, Comp, Proj> constexpr I ranges::sort(I first, S last, Comp comp = {}, Proj proj = {}); template<RandomAccessRange R, class Comp = ranges::less, class Proj = identity> requires Sortable<iterator_t<R>, Comp, Proj> constexpr safe_iterator_t<R> ranges::sort(R&& r, Comp comp = {}, Proj proj = {});
Let comp be less{} and proj be identity{} for the overloads with no parameters by those names.
Requires: For the overloads in namespace std, RandomAccessIterator shall meet the Cpp17ValueSwappable requirements ([swappable.requirements]) and the type of *first shall meet the Cpp17MoveConstructible ([tab:moveconstructible]Table *tab:moveconstructible) and Cpp17MoveAssignable ([tab:moveassignable]Table *tab:moveassignable) requirements.
Effects: Sorts the elements in the range [first, last) with respect to comp and proj.
Returns: last, for the overloads in namespace ranges.
Complexity: Let N be last - first.
comparisons and projections.