Method By
- Namespace
- SodaFlow.Collections
- Assembly
- SodaFlow.Core.Collections.dll
By<TSortKey>(Func<TIdentity, TState, TSortKey>)
Orders by a value projected from each item.
public static KeyOrder<TKey, TIdentity, TState> By<TSortKey>(Func<TIdentity, TState, TSortKey> selector)
Parameters
selectorFunc<TIdentity, TState, TSortKey>Projects the sort value from an item.
Returns
- KeyOrder<TKey, TIdentity, TState>
The order.
Type Parameters
TSortKeyThe type of the projected sort value.
By<TSortKey>(Func<TIdentity, TState, TSortKey>, IComparer<TSortKey>, IComparer<TKey>, bool)
Orders by a value from each item. 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 KeyOrder<TKey, TIdentity, TState> By<TSortKey>(Func<TIdentity, TState, TSortKey> selector, IComparer<TSortKey> sortComparer, IComparer<TKey> keyComparer, bool isDescending)
Parameters
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
- KeyOrder<TKey, TIdentity, TState>
The order.
Type Parameters
TSortKeyThe type of the projected sort value.