11 Algorithms library [algorithms]

11.5 Sorting and related operations [alg.sorting]

11.5.1 Sorting [alg.sort]

11.5.1.1 sort [sort]

template <RandomAccessIterator I, Sentinel<I> S, class Comp = less<>, class Proj = identity> requires Sortable<I, Comp, Proj> I sort(I first, S last, Comp comp = Comp{}, Proj proj = Proj{}); template <RandomAccessRange Rng, class Comp = less<>, class Proj = identity> requires Sortable<iterator_t<Rng>, Comp, Proj> safe_iterator_t<Rng> sort(Rng&& rng, Comp comp = Comp{}, Proj proj = Proj{});

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

Returns: last.

Complexity: Ο(Nlog(N)) (where N == last - first) comparisons, and twice as many applications of the projection.