maybeSortBy

Maybe sorts a range using maybeSort by a publicly visible member variable or property of ElemntType!Range

ref
maybeSortBy
(
string member
alias less = null
Range
)
(
auto ref Range range
)

Examples

1 import bolts.range: isSortedRange;
2 
3 struct A { // unsortable
4     int i;
5 }
6 
7 struct B { // sortable
8     int i;
9     bool opCmp(B a) {
10         return i < a.i;
11     }
12 }
13 
14 struct C {
15     B b;
16     A a;
17 }
18 
19 static assert(!isSortedRange!([C()].maybeSortBy!"a"));
20 static assert( isSortedRange!([C()].maybeSortBy!"b"));
21 static assert( isSortedRange!([C()].maybeSortBy!("a", "a.i < b.i")));

Meta

Since

0.0.1