orderBy method
Sort items
Implementation
Iterable<T> orderBy(
num Function(T item) order, {
bool desc = false,
}) sync* {
final sorted = toList();
if (desc) {
sorted.sort(
(a, b) => order(b) > order(a)
? 1
: order(b) < order(a)
? -1
: 0,
);
} else {
sorted.sort(
(a, b) => order(b) < order(a)
? 1
: order(b) > order(a)
? -1
: 0,
);
}
for (final item in sorted) {
yield item;
}
}