Method Rank
View SourceRank<TSource>(IEnumerable<TSource>)
Ranks each item in the sequence in ascending order using a default comparer. The rank is equal to index + 1 of the first element of the item's equality set.
Declaration
public static IEnumerable<(TSource item, int rank)> Rank<TSource>(this IEnumerable<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TSource> | source | The sequence whose items will be ranked |
Returns
Type | Description |
---|---|
IEnumerable<(TSource item, int rank)> | A sorted sequence of items and their rank. |
Type Parameters
Name | Description |
---|---|
TSource | Type of item in the sequence |
Remarks
This method is implemented by using deferred execution. However, source
will be consumed
in it's entirety immediately when first element of the returned sequence is consumed.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Rank<TSource>(IEnumerable<TSource>, IComparer<TSource>)
Ranks each item in the sequence in ascending order 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 IEnumerable<(TSource item, int rank)> Rank<TSource>(this IEnumerable<TSource> source, IComparer<TSource> comparer)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TSource> | source | The sequence of items to rank |
IComparer<TSource> | comparer | A object that defines comparison semantics for the elements in the sequence |
Returns
Type | Description |
---|---|
IEnumerable<(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 |
Remarks
This method is implemented by using deferred execution. However, source
will be consumed
in it's entirety immediately when first element of the returned sequence is consumed.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Rank<TSource>(IEnumerable<TSource>, OrderByDirection)
Ranks each item in the sequence in the order defined by sortDirection
using a default
comparer. The rank is equal to index + 1 of the first element of the item's equality set.
Declaration
public static IEnumerable<(TSource item, int rank)> Rank<TSource>(this IEnumerable<TSource> source, OrderByDirection sortDirection)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TSource> | source | The sequence whose items will be ranked |
OrderByDirection | sortDirection | Defines the ordering direction for the sequence |
Returns
Type | Description |
---|---|
IEnumerable<(TSource item, int rank)> | A sorted sequence of items and their rank. |
Type Parameters
Name | Description |
---|---|
TSource | Type of item in the sequence |
Remarks
This method is implemented by using deferred execution. However, source
will be consumed
in it's entirety immediately when first element of the returned sequence is consumed.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Rank<TSource>(IEnumerable<TSource>, IComparer<TSource>, OrderByDirection)
Ranks each item in the sequence in the order defined by sortDirection
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 IEnumerable<(TSource item, int rank)> Rank<TSource>(this IEnumerable<TSource> source, IComparer<TSource> comparer, OrderByDirection sortDirection)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TSource> | source | The sequence of items to rank |
IComparer<TSource> | comparer | A object that defines comparison semantics for the elements in the sequence |
OrderByDirection | sortDirection | Defines the ordering direction for the sequence |
Returns
Type | Description |
---|---|
IEnumerable<(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 |
Remarks
This method is implemented by using deferred execution. However, source
will be consumed
in it's entirety immediately when first element of the returned sequence is consumed.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|