xtd 0.2.0
Loading...
Searching...
No Matches
xtd::ranges::views::order_by_view Class Reference

Definition

The xtd::ranges::views::order_by_view class is used to sort the elements of a sequence in ascending order according to a key.

Definition
The xtd::ranges::views::order_by_view class is used to sort the elements of a sequence in ascending o...
Definition order_by_view.hpp:44
Header
#include <xtd/ranges/views/order_by_view>
Namespace
xtd::ranges::views
Library
xtd.core
Examples
The following example shows how to use xtd::ranges::views::order_by instance :
#include <xtd/xtd>
auto main() -> int {
auto numbers = array {2, 7, 3, 1, 4, 10, 5, 6, 8, 9};
console::write_line("numbers = {}", numbers | order_by([](auto n) {return n;}));
}
// This code produces the following output :
//
// numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:63
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
constexpr auto order_by
The xtd::ranges::views::order_by instance.
Definition order_by.hpp:40
@ n
The N key.
Definition console_key.hpp:114
The following example shows how to use xtd::ranges::views::order_by_view class :
#include <xtd/xtd>
auto main() -> int {
auto numbers = array {2, 7, 3, 1, 4, 10, 5, 6, 8, 9};
console::write_line("numbers = {}", order_by(numbers, [](auto n) {return n;}));
}
// This code produces the following output :
//
// numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Public Operators

template<std::ranges::range range_t, typename key_selector_t>
auto operator() (range_t &&source, const key_selector_t &key_selector) const
 Sorts the elements of a sequence in ascending order according to a key.
 
template<typename key_selector_t>
auto operator() (const key_selector_t &key_selector) const
 Sorts the elements of a sequence in ascending order according to a key.
 

Member Function Documentation

◆ operator()() [1/2]

template<std::ranges::range range_t, typename key_selector_t>
auto xtd::ranges::views::order_by_view::operator() ( range_t && source,
const key_selector_t & key_selector ) const
inline

Sorts the elements of a sequence in ascending order according to a key.

Template Parameters
range_tThe type of the elements of source.
Parameters
sourceA sequence of values to sort.
key_selectorA function to extract a key from an element.

◆ operator()() [2/2]

template<typename key_selector_t>
auto xtd::ranges::views::order_by_view::operator() ( const key_selector_t & key_selector) const
inline

Sorts the elements of a sequence in ascending order according to a key.

Template Parameters
range_tThe type of the elements of source.
Parameters
key_selectorA function to extract a key from an element.

The documentation for this class was generated from the following file: