#include <xtd/xtd>
struct my_own_descending_comparer : icomparer<int> {
[[nodiscard]] auto compare(const int& x, const int& y) const -> int override {return x > y ? -1 : x < y ? 1 : 0;}
};
auto main() -> int {
auto items = list {10, 6, 5, 7, 8, 2, 9, 3, 1, 4};
items.sort(2, 6, _1 < _2);
println(
"ascending sorted items = {}", items);
items.sort(2, 6, _1 > _2);
println(
"descending sorted items = {}", items);
items.sort(2, 6, _1 <=> _2);
println(
"ascending sorted items = {}", items);
items.sort(2, 6, _1 <=> _2 == std::strong_ordering::greater);
println(
"descending sorted items = {}", items);
println(
"ascending sorted items = {}", items);
items.sort(2, 6, [](
auto&& a,
auto&& b) {
return a >
b ? -1 :
a <
b ? 1 : 0;});
println(
"descending sorted items = {}", items);
items.sort(2, 6, comparer<int>::default_comparer);
println(
"ascending sorted items = {}", items);
items.sort(2, 6, my_own_descending_comparer {});
println(
"descending sorted items = {}", items);
}
constexpr auto if_then_else(condition_t condition, then_t then_, else_t else_)
If condition is true return then_ else retur nelse_.
Definition if_then_else_expression.hpp:92
@ a
The A key.
Definition console_key.hpp:88
@ b
The B key.
Definition console_key.hpp:90
auto println(FILE *file) -> void
Writes the current line terminator to the file output stream using the specified format information.
Definition println.hpp:15