MoreEnumerable.OrderBy<T, TKey>(IEnumerable<T>, Func<T, TKey>, IComparer<TKey>, OrderByDirection) Method

Sorts the elements of a sequence in a particular direction (ascending, descending) according to a key

Definition

Namespace: MoreLinq
Assembly: MoreLinq (in MoreLinq.dll) Version: 4.1.0+0e154ef592f33ce0f6f3d534a9eedee273f0ce72
C#
public static IOrderedEnumerable<T> OrderBy<T, TKey>(
	this IEnumerable<T> source,
	Func<T, TKey> keySelector,
	IComparer<TKey>? comparer,
	OrderByDirection direction
)

Parameters

source  IEnumerable<T>
The sequence to order
keySelector  Func<T, TKey>
A key selector function
comparer  IComparer<TKey>
A comparer used to define the semantics of element comparison
direction  OrderByDirection
A direction in which to order the elements (ascending, descending)

Type Parameters

T
The type of the elements in the source sequence
TKey
The type of the key used to order elements

Return Value

IOrderedEnumerable<T>
An ordered copy of the source sequence

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<T>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also