EnumerableExtensions.OrderBy method

Version 1.1.28
.NET Framework 4.8
Namespace Skybrud.Essentials.Collections.Extensions
Assembly Skybrud.Essentials.dll

OrderBy<T,TKey>(IEnumerable<T>, Func<T, TResult>, bool)

Extension method

Orders collection in descending order if reverse is true, otherwise in ascending order.

public static IOrderedEnumerable<TElement> OrderBy<T,TKey>(this IEnumerable<T> collection, Func<T, TResult> func, bool reverse)

Type Parameters

T

The type of the items in the collection.

TKey

Parameters

collection IEnumerable<T>

The collection to be sorted.

func Func<T, TResult>

The callback function used for sorting the items.

reverse bool

Whether collection should be sorted in descending order.

Returns

IOrderedEnumerable<TElement>

An instanced of IOrderedEnumerable<TElement>.

OrderBy<T,TKey>(IEnumerable<T>, Func<T, TResult>, SortOrder)

Extension method

Orders collection in descending order if order is Descending, otherwise in ascending order.

public static IOrderedEnumerable<TElement> OrderBy<T,TKey>(this IEnumerable<T> collection, Func<T, TResult> func, SortOrder order)

Type Parameters

T

The type of the items in the collection.

TKey

Parameters

collection IEnumerable<T>

The collection to be sorted.

func Func<T, TResult>

The callback function used for sorting the items.

order SortOrder

The order by which the collection should be sorted.

Returns

IOrderedEnumerable<TElement>

An instanced of IOrderedEnumerable<TElement>.

OrderBy<T,TKey>(IEnumerable<T>, Func<T, TResult>, IComparer<T>, bool)

Extension method

Sorts the elements of source in descending order if reverse is true, otherwise in ascending order.

public static IOrderedEnumerable<TElement> OrderBy<T,TKey>(this IEnumerable<T> source, Func<T, TResult> func, IComparer<T> comparer, bool reverse)

Type Parameters

T

The type of the items in the collection.

TKey

Parameters

source IEnumerable<T>

The collection to be sorted.

func Func<T, TResult>

The callback function used for sorting the items.

comparer IComparer<T>

An IComparer<T> to compare the keys.

reverse bool

Whether source should be sorted in descending order.

Returns

IOrderedEnumerable<TElement>

An instanced of IOrderedEnumerable<TElement>.

OrderBy<TSource,TKey>(IEnumerable<T>, Func<T, TResult>, IComparer<T>, SortOrder)

Extension method

Orders source in descending order if order is Descending, otherwise in ascending order.

public static IOrderedEnumerable<TElement> OrderBy<TSource,TKey>(this IEnumerable<T> source, Func<T, TResult> keySelector, IComparer<T> comparer, SortOrder order)

Type Parameters

TSource

The type of the elements of source.

TKey

The type of the key returned by keySelector.

Parameters

source IEnumerable<T>

A sequence of values to order.

keySelector Func<T, TResult>

A function to extract a key from an element.

comparer IComparer<T>

An IComparer<T> to compare the keys.

order SortOrder

The order by which the collection should be sorted.

Returns

IOrderedEnumerable<TElement>

An instanced of IOrderedEnumerable<TElement>.