Method SortBy
- Namespace
- SodaFlow.Collections
- Assembly
- SodaFlow.Collections.dll
SortBy<TKey, TIdentity, TState, TSortKey>(ReactiveCollection<TKey, TIdentity, TState>, Func<TIdentity, TState, TSortKey>)
Reorders the view by a value projected from each item.
public static ReactiveCollection<TKey, TIdentity, TState> SortBy<TKey, TIdentity, TState, TSortKey>(this ReactiveCollection<TKey, TIdentity, TState> upstream, Func<TIdentity, TState, TSortKey> selector) where TKey : notnull where TIdentity : notnull
Parameters
upstreamReactiveCollection<TKey, TIdentity, TState>The collection or view to reorder.
selectorFunc<TIdentity, TState, TSortKey>Projects the sort value from an item.
Returns
- ReactiveCollection<TKey, TIdentity, TState>
A view ordered by that value.
Type Parameters
TKeyThe type of the keys.
TIdentityThe type of the immutable part of an item.
TStateThe type of the mutable part of an item.
TSortKeyThe type of the projected sort value.
SortBy<TKey, TIdentity, TState, TSortKey>(ReactiveCollection<TKey, TIdentity, TState>, Func<TIdentity, TState, TSortKey>, IComparer<TSortKey>, IComparer<TKey>, bool)
Reorders the view. TSortKey stays a generic
parameter to the comparer, thus this code keeps and compares each sort
value as its own type and never boxes it.
public static ReactiveCollection<TKey, TIdentity, TState> SortBy<TKey, TIdentity, TState, TSortKey>(this ReactiveCollection<TKey, TIdentity, TState> upstream, Func<TIdentity, TState, TSortKey> selector, IComparer<TSortKey> sortComparer, IComparer<TKey> keyComparer, bool isDescending) where TKey : notnull where TIdentity : notnull
Parameters
upstreamReactiveCollection<TKey, TIdentity, TState>The collection or view to reorder.
selectorFunc<TIdentity, TState, TSortKey>Projects the sort value from an item.
sortComparerIComparer<TSortKey>Compares two projected sort values.
keyComparerIComparer<TKey>Compares two keys with equal sort values, thus the order is total.
isDescendingboolTrue when the sort uses the opposite direction.
Returns
- ReactiveCollection<TKey, TIdentity, TState>
A view in that order.
Type Parameters
TKeyThe type of the keys.
TIdentityThe type of the immutable part of an item.
TStateThe type of the mutable part of an item.
TSortKeyThe type of the projected sort value.
SortBy<TKey, TIdentity, TState>(ReactiveCollection<TKey, TIdentity, TState>, Cell<KeyOrder<TKey, TIdentity, TState>>)
Reorders the view by whichever order the cell currently holds.
public static ReactiveCollection<TKey, TIdentity, TState> SortBy<TKey, TIdentity, TState>(this ReactiveCollection<TKey, TIdentity, TState> upstream, Cell<KeyOrder<TKey, TIdentity, TState>> orderCell) where TKey : notnull where TIdentity : notnull
Parameters
upstreamReactiveCollection<TKey, TIdentity, TState>The collection or view to reorder.
orderCellCell<KeyOrder<TKey, TIdentity, TState>>The order for the sort. It can change.
Returns
- ReactiveCollection<TKey, TIdentity, TState>
A view in whichever order that cell holds.
Type Parameters
TKeyThe type of the keys.
TIdentityThe type of the immutable part of an item.
TStateThe type of the mutable part of an item.
Remarks
This stage is the base of the other sorts, and the order of each one does not change. This stage is also the shape of a column header that a user can click. Build the orders with the factories of KeyOrder<TKey, TIdentity, TState>, which are the equivalent of those sorts. An order holds its own sort value type, thus one cell can hold orders that sort on values of different types.
A new order is a change of criteria, as each other criteria is. It builds this stage again and reports a reset. A stage below sorts again in the new order and no code tells it to, because a filter builds from the current order of its upstream. It is always a reset, also when the new order is the previous order in the opposite direction. A change of order is never a set of moves, because a move is for a key that a change of value moved.
SortBy<TKey, TIdentity, TState>(ReactiveCollection<TKey, TIdentity, TState>, KeyOrder<TKey, TIdentity, TState>)
Reorders the view by an order that does not change.
public static ReactiveCollection<TKey, TIdentity, TState> SortBy<TKey, TIdentity, TState>(this ReactiveCollection<TKey, TIdentity, TState> upstream, KeyOrder<TKey, TIdentity, TState> order) where TKey : notnull where TIdentity : notnull
Parameters
upstreamReactiveCollection<TKey, TIdentity, TState>The collection or view to reorder.
orderKeyOrder<TKey, TIdentity, TState>The order to sort by.
Returns
- ReactiveCollection<TKey, TIdentity, TState>
A view in that order.
Type Parameters
TKeyThe type of the keys.
TIdentityThe type of the immutable part of an item.
TStateThe type of the mutable part of an item.
Remarks
This is the shape of a sort with more than one level whose levels do not
change. Build the order with the factories of
KeyOrder<TKey, TIdentity, TState> and with ThenBy, and
give it here. An order that changes goes in a cell. See the overload that
takes one.