Table of Contents

Method ThenBy

Namespace
SodaFlow.Collections
Assembly
SodaFlow.Core.Collections.dll

ThenBy<TSortKey>(Func<TIdentity, TState, TSortKey>)

This order, with its ties broken by a value projected from each item.

public KeyOrder<TKey, TIdentity, TState> ThenBy<TSortKey>(Func<TIdentity, TState, TSortKey> selector)

Parameters

selector Func<TIdentity, TState, TSortKey>

Projects the next level's sort value from an item.

Returns

KeyOrder<TKey, TIdentity, TState>

The refined order. This order does not change, and other code can use it alone.

Type Parameters

TSortKey

The type of the projected sort value.

Remarks

This is the equivalent of ThenBy after OrderBy. The new level selects only between keys that this order ranks equal. Each level keeps its own sort value type to its comparer, thus this code boxes nothing at each count of levels. The key is the last level, with the comparer of the first level.

ThenBy<TSortKey>(Func<TIdentity, TState, TSortKey>, IComparer<TSortKey>, bool)

This order, with its ties broken by a value projected from each item.

public KeyOrder<TKey, TIdentity, TState> ThenBy<TSortKey>(Func<TIdentity, TState, TSortKey> selector, IComparer<TSortKey> sortComparer, bool isDescending)

Parameters

selector Func<TIdentity, TState, TSortKey>

Projects the next level's sort value from an item.

sortComparer IComparer<TSortKey>

Compares two of the next level's sort values.

isDescending bool

True when this level uses the opposite direction, at each direction of the levels above it.

Returns

KeyOrder<TKey, TIdentity, TState>

The refined order. This order does not change, and other code can use it alone.

Type Parameters

TSortKey

The type of the projected sort value.

Remarks

There is no key comparer for this call. The key is the last level in each order, and the construction of the first level selected the comparer for it.