EnumerableExtensions.OrderBy method
Namespace | Skybrud.Essentials.Collections.Extensions |
---|---|
Assembly | Skybrud.Essentials.dll |
OrderBy<T,TKey>(IEnumerable<T>, Func<T, TResult>, bool)
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
The collection to be sorted.
The callback function used for sorting the items.
reverse
bool
Whether collection
should be sorted in descending order.
Returns
TElement
>
An instanced of IOrderedEnumerable<TElement
>.
OrderBy<T,TKey>(IEnumerable<T>, Func<T, TResult>, SortOrder)
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
The collection to be sorted.
The callback function used for sorting the items.
order
SortOrder
The order by which the collection should be sorted.
Returns
TElement
>
An instanced of IOrderedEnumerable<TElement
>.
OrderBy<T,TKey>(IEnumerable<T>, Func<T, TResult>, IComparer<T>, bool)
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
The collection to be sorted.
The callback function used for sorting the items.
reverse
bool
Whether source
should be sorted in descending order.
Returns
TElement
>
An instanced of IOrderedEnumerable<TElement
>.
OrderBy<TSource,TKey>(IEnumerable<T>, Func<T, TResult>, IComparer<T>, SortOrder)
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
A sequence of values to order.
A function to extract a key from an element.
order
SortOrder
The order by which the collection should be sorted.
Returns
TElement
>
An instanced of IOrderedEnumerable<TElement
>.