Επεξεργασία

Κοινή χρήση μέσω


Enumerable.Order Method

Definition

Overloads

Order<T>(IEnumerable<T>)

Sorts the elements of a sequence in ascending order.

Order<T>(IEnumerable<T>, IComparer<T>)

Sorts the elements of a sequence in ascending order.

Order<T>(IEnumerable<T>)

Source:
OrderBy.cs
Source:
OrderBy.cs
Source:
OrderBy.cs

Sorts the elements of a sequence in ascending order.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::IOrderedEnumerable<T> ^ Order(System::Collections::Generic::IEnumerable<T> ^ source);
public static System.Linq.IOrderedEnumerable<T> Order<T> (this System.Collections.Generic.IEnumerable<T> source);
static member Order : seq<'T> -> System.Linq.IOrderedEnumerable<'T>
<Extension()>
Public Function Order(Of T) (source As IEnumerable(Of T)) As IOrderedEnumerable(Of T)

Type Parameters

T

The type of the elements of source.

Parameters

source
IEnumerable<T>

A sequence of values to order.

Returns

An IOrderedEnumerable<TElement> whose elements are sorted.

Exceptions

source is null.

Remarks

This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated by calling its <see cref="M:System.Collections.Generic.IEnumerable`1.GetEnumerator> method.

This method compares elements by using the default comparer <see cref="P:System.Collections.Generic.Comparer`1.Default>.

Applies to

Order<T>(IEnumerable<T>, IComparer<T>)

Source:
OrderBy.cs
Source:
OrderBy.cs
Source:
OrderBy.cs

Sorts the elements of a sequence in ascending order.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::IOrderedEnumerable<T> ^ Order(System::Collections::Generic::IEnumerable<T> ^ source, System::Collections::Generic::IComparer<T> ^ comparer);
public static System.Linq.IOrderedEnumerable<T> Order<T> (this System.Collections.Generic.IEnumerable<T> source, System.Collections.Generic.IComparer<T>? comparer);
static member Order : seq<'T> * System.Collections.Generic.IComparer<'T> -> System.Linq.IOrderedEnumerable<'T>
<Extension()>
Public Function Order(Of T) (source As IEnumerable(Of T), comparer As IComparer(Of T)) As IOrderedEnumerable(Of T)

Type Parameters

T

The type of the elements of source.

Parameters

source
IEnumerable<T>

A sequence of values to order.

comparer
IComparer<T>

An IComparer<T> to compare keys.

Returns

An IOrderedEnumerable<TElement> whose elements are sorted.

Exceptions

source is null.

Remarks

This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated by calling its <see cref="M:System.Collections.Generic.IEnumerable`1.GetEnumerator> method.

If comparer is null, the default comparer <see cref="P:System.Collections.Generic.Comparer`1.Default> is used to compare elements.

See also

Applies to