std::experi...ranges::sort(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… std::experimental::ranges::sort πŸ’…

okay so bestie, this is the C++ Standard Libary manual page for std::experimental::ranges::sort. The header calls it std::experi...ranges::sort(3), and yes, the truncation is iconic in its own chaotic way. We're in ranges TS territory, so there's projections, comparators, and a whole vibe. Let's get into it. 🫢


✨ NAME ✨

std::experimental::ranges::sort β€” std::experimental::ranges::sort


🌸 Synopsis 🌸

Defined in header <experimental/ranges/algorithm>

template< RandomAccessIterator I, Sentinel<I> S,

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

I sort( I first, S last, Comp comp = Comp{}, Proj proj = Proj{} );
template< RandomAccessRange R,

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

ranges::safe_iterator_t<R> sort( R&& r, Comp comp = Comp{}, Proj
proj = Proj{} );
  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 r, as if by return ranges::sort(ranges::begin(r), ranges::end(r), comp, proj);.
⚠️ Important caveat, fr fr: Notwithstanding the declarations depicted above, the actual number and order of template parameters for algorithm declarations is unspecified. Thus, if explicit template arguments are used when calling an algorithm, the program is probably non-portable.

πŸŽ€ Parameters πŸŽ€

  • first, last β€” the range of elements to sort.
  • r β€” the range of elements to sort.
  • comp β€” the comparator to use.
  • proj β€” the projection to apply to elements in 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(r) for overload (2)).


πŸ”₯ Complexity πŸ”₯

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


πŸ¦‹ Example πŸ¦‹

This section is incomplete Reason: no example

bestie, it's giving unfinished, but that's literally what the page says. πŸ™ˆ


πŸ‘‘ See also πŸ‘‘

  • sort β€” sorts a range into ascending order (function template)

πŸ’€ Category πŸ’€

  • Todo no example

stay hydrated and sorted, bestie πŸ’– β€” source/version http://cppreference.com, date 2024.06.10, page std::experi...ranges::sort(3).

πŸ“¦ where this page comes from