Sorting
order_by
Sorts the range using a key selector function (key_selector
) according to a direction
(sort_dir
).
key_selector
must be a function that takes the range's elements as input and returns a
value of an arbitrary type, i.e. \(f(x) \mapsto y\). The result value (of type y
) is then
used as the sorting key in the subsequent sorting algorithm.
sort_dir
specifies whether the elements are sorted in ascending or descending order.
Comparison is done using operator<
between elements of type y
.
Signature
template <typename TKeySelector>
constexpr auto order_by( TKeySelector&& key_selector, sort_direction sort_dir ) const;
then_by
Sorts a range that was produced by order_by
and serves to apply subsequent sorting criteria.
A then_by
operation can only be applied to a order_by
range.
Applying this operator to another kind of range will result in a compile-time error.
Signature
template <typename TKeySelector>
constexpr auto then_by( TKeySelector&& key_selector, sort_direction sort_dir ) const;
reverse
Reverses the order of the range.