Method DenseRankBy
View SourceDenseRankBy<TSource, TKey>(IAsyncEnumerable<TSource>, Func<TSource, TKey>)
Ranks each item in the sequence in ascending order by a specified key using a default comparer, with no gaps in the ranking values. The rank starts at one and keeps incrementing by one for each different item.
Declaration
public static IAsyncEnumerable<(TSource item, int rank)> DenseRankBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The sequence of items to rank |
Func<TSource, TKey> | keySelector | A key selector function which returns the value by which to rank items in the sequence |
Returns
Type | Description |
---|---|
IAsyncEnumerable<(TSource item, int rank)> | A sorted sequence of items and their rank. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the source sequence |
TKey | The type of the key used to rank items in the sequence |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
DenseRankBy<TSource, TKey>(IAsyncEnumerable<TSource>, Func<TSource, TKey>, OrderByDirection)
Ranks each item in the sequence in the order defined by sortDirection
by a specified key using a default comparer, with no gaps in the ranking values.
The rank starts at one and keeps incrementing by one for each different item.
Declaration
public static IAsyncEnumerable<(TSource item, int rank)> DenseRankBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, OrderByDirection sortDirection)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The sequence of items to rank |
Func<TSource, TKey> | keySelector | A key selector function which returns the value by which to rank items in the sequence |
OrderByDirection | sortDirection | Defines the ordering direction for the sequence |
Returns
Type | Description |
---|---|
IAsyncEnumerable<(TSource item, int rank)> | A sorted sequence of items and their rank. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the source sequence |
TKey | The type of the key used to rank items in the sequence |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
DenseRankBy<TSource, TKey>(IAsyncEnumerable<TSource>, Func<TSource, TKey>, IComparer<TKey>)
Ranks each item in the sequence in ascending order by a specified key using a caller-supplied comparer, with no gaps in the ranking values. The rank starts at one and keeps incrementing by one for each different item.
Declaration
public static IAsyncEnumerable<(TSource item, int rank)> DenseRankBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The sequence of items to rank |
Func<TSource, TKey> | keySelector | A key selector function which returns the value by which to rank items in the sequence |
IComparer<TKey> | comparer | An object that defines the comparison semantics for keys used to rank items |
Returns
Type | Description |
---|---|
IAsyncEnumerable<(TSource item, int rank)> | A sorted sequence of items and their rank. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the source sequence |
TKey | The type of the key used to rank items in the sequence |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
DenseRankBy<TSource, TKey>(IAsyncEnumerable<TSource>, Func<TSource, TKey>, IComparer<TKey>, OrderByDirection)
Ranks each item in the sequence in the order defined by sortDirection
by a specified key using a caller-supplied comparer, with no gaps in the ranking values.
The rank starts at one and keeps incrementing by one for each different item.
Declaration
public static IAsyncEnumerable<(TSource item, int rank)> DenseRankBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer, OrderByDirection sortDirection)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The sequence of items to rank |
Func<TSource, TKey> | keySelector | A key selector function which returns the value by which to rank items in the sequence |
IComparer<TKey> | comparer | An object that defines the comparison semantics for keys used to rank items |
OrderByDirection | sortDirection | Defines the ordering direction for the sequence |
Returns
Type | Description |
---|---|
IAsyncEnumerable<(TSource item, int rank)> | A sorted sequence of items and their rank. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the source sequence |
TKey | The type of the key used to rank items in the sequence |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|