Table of Contents

Method SortByIdentity

Namespace
SodaFlow.Collections
Assembly
SodaFlow.Collections.dll

SortByIdentity<TKey, TIdentity, TState, TSortKey>(ReactiveCollection<TKey, TIdentity, TState>, Func<TIdentity, TSortKey>)

Reorders the view by a value from the immutable part of each item, which is its identity. A state edit cannot change that part.

public static ReactiveCollection<TKey, TIdentity, TState> SortByIdentity<TKey, TIdentity, TState, TSortKey>(this ReactiveCollection<TKey, TIdentity, TState> upstream, Func<TIdentity, TSortKey> selector) where TKey : notnull where TIdentity : notnull

Parameters

upstream ReactiveCollection<TKey, TIdentity, TState>

The collection or view to reorder.

selector Func<TIdentity, TSortKey>

Projects the sort value from an item's identity.

Returns

ReactiveCollection<TKey, TIdentity, TState>

A view ordered by that value.

Type Parameters

TKey

The type of the keys.

TIdentity

The type of the immutable part of an item.

TState

The type of the mutable part of an item.

TSortKey

The type of the projected sort value.

Remarks

This gives the same order as SortBy for the same values, and it costs less to keep. A state edit cannot move a key in this order, thus a stage does not sort a key again when it hears only that the key changed, and the construction of the stage never reads the state map. This is not a statement that a reader must accept. The selector receives the identity and not the state, thus it cannot read the state that it says it does not read.

SortByIdentity<TKey, TIdentity, TState, TSortKey>(ReactiveCollection<TKey, TIdentity, TState>, Func<TIdentity, TSortKey>, IComparer<TSortKey>, IComparer<TKey>, bool)

Reorders the view by a value from the identity of each item, with explicit comparers.

public static ReactiveCollection<TKey, TIdentity, TState> SortByIdentity<TKey, TIdentity, TState, TSortKey>(this ReactiveCollection<TKey, TIdentity, TState> upstream, Func<TIdentity, TSortKey> selector, IComparer<TSortKey> sortComparer, IComparer<TKey> keyComparer, bool isDescending) where TKey : notnull where TIdentity : notnull

Parameters

upstream ReactiveCollection<TKey, TIdentity, TState>

The collection or view to reorder.

selector Func<TIdentity, TSortKey>

Projects the sort value from an item's identity.

sortComparer IComparer<TSortKey>

Compares two projected sort values.

keyComparer IComparer<TKey>

Compares two keys with equal sort values, thus the order is total.

isDescending bool

True when the sort uses the opposite direction.

Returns

ReactiveCollection<TKey, TIdentity, TState>

A view in that order.

Type Parameters

TKey

The type of the keys.

TIdentity

The type of the immutable part of an item.

TState

The type of the mutable part of an item.

TSortKey

The type of the projected sort value.