Method RankBy
View SourceRankBy<TSource, TKey>(IAsyncEnumerable<TSource>, Func<TSource, TKey>)
Ranks each item in the sequence in ascending order by a specified key using a default comparer. The rank is equal to index + 1 of the first element of the item's equality set.
Declaration
public static IAsyncEnumerable<(TSource item, int rank)> RankBy<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 |
|
RankBy<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. The rank is equal to index + 1 of the first
element of the item's equality set.
Declaration
public static IAsyncEnumerable<(TSource item, int rank)> RankBy<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 |
|
RankBy<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. The rank is equal to index + 1 of the first element of the item's equality set.
Declaration
public static IAsyncEnumerable<(TSource item, int rank)> RankBy<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 |
|
RankBy<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. The rank is equal to index + 1 of the first
element of the item's equality set.
Declaration
public static IAsyncEnumerable<(TSource item, int rank)> RankBy<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 |
|