std::experimental::ranges::sort

From cppreference.com
< cpp‎ | experimental‎ | ranges
 
 
Technical specifications
Filesystem library (filesystem TS)
Library fundamentals (library fundamentals TS)
Library fundamentals 2 (library fundamentals 2 TS)
Extensions for parallelism (parallelism TS)
Extensions for concurrency (concurrency TS)
Concepts (concepts TS)
Ranges (ranges TS)
Special mathematical functions (special math TR)
 
 
 
template< ranges::RandomAccessIterator I, ranges::Sentinel<I> S,

          class Comp = ranges::less<>, class Proj = ranges::identity>
  requires ranges::Sortable<I, Comp, Proj>()

I sort( I first, S last, Comp comp = Comp{}, Proj proj = Proj{} );
(1) (ranges TS)
template< ranges::RandomAccessRange Rng,

          class Comp = ranges::less<>, class Proj = ranges::identity>
  requires ranges::Sortable<ranges::iterator_t<Rng>, Comp, Proj>()

ranges::safe_iterator_t<Rng> sort( Rng&& rng, Comp comp = Comp{}, Proj proj = Proj{} );
(2) (ranges TS)
1) Sorts the elements in the range [first, last) in ascending order. The order of equal elements is not guaranteed to be preserved. Elements are compared using comp after applying the projection proj.
2) Sorts the elements in the range rng, as if by return ranges::sort(ranges::begin(rng), ranges::end(rng), comp, proj);

Parameters

first, last - the range of elements to sort
rng - the range of elements to sort
comp - the comparator to use
proj - the projection to apply to elements to the range

Return value

An iterator pointing past the end of the range (i.e., it compares equal to last for overload (1), and ranges::end(rng) for overload (2)).

Complexity

O(N·log(N)) comparisons, where N is equal to the number of elements in the range.

Example

See also

sorts a range into ascending order
(function template)