Прочетете на английски Редактиране

Споделяне чрез


ParallelEnumerable.OrderBy Method

Definition

Sorts in parallel the elements of a sequence in ascending order.

Overloads

OrderBy<TSource,TKey>(ParallelQuery<TSource>, Func<TSource,TKey>)

Sorts in parallel the elements of a sequence in ascending order according to a key.

OrderBy<TSource,TKey>(ParallelQuery<TSource>, Func<TSource,TKey>, IComparer<TKey>)

Sorts in parallel the elements of a sequence in ascending order by using a specified comparer.

OrderBy<TSource,TKey>(ParallelQuery<TSource>, Func<TSource,TKey>)

Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs

Sorts in parallel the elements of a sequence in ascending order according to a key.

C#
public static System.Linq.OrderedParallelQuery<TSource> OrderBy<TSource,TKey>(this System.Linq.ParallelQuery<TSource> source, Func<TSource,TKey> keySelector);

Type Parameters

TSource

The type of elements of source.

TKey

The type of the key returned by keySelector.

Parameters

source
ParallelQuery<TSource>

A sequence of values to order.

keySelector
Func<TSource,TKey>

A function to extract a key from an element.

Returns

An OrderedParallelQuery{TSource} whose elements are sorted according to a key.

Exceptions

source or keySelector is a null reference (Nothing in Visual Basic).

One or more exceptions occurred during the evaluation of the query.

Remarks

In contrast to the sequential implementation, this is not a stable sort. To achieve a stable sort, change a query of the form: var ordered = source.Select((e,i) => new { E=e, I=i }).OrderBy((v) => v.e).ThenBy(v => v.i).Select((v) => v.e);

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

OrderBy<TSource,TKey>(ParallelQuery<TSource>, Func<TSource,TKey>, IComparer<TKey>)

Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs

Sorts in parallel the elements of a sequence in ascending order by using a specified comparer.

C#
public static System.Linq.OrderedParallelQuery<TSource> OrderBy<TSource,TKey>(this System.Linq.ParallelQuery<TSource> source, Func<TSource,TKey> keySelector, System.Collections.Generic.IComparer<TKey> comparer);
C#
public static System.Linq.OrderedParallelQuery<TSource> OrderBy<TSource,TKey>(this System.Linq.ParallelQuery<TSource> source, Func<TSource,TKey> keySelector, System.Collections.Generic.IComparer<TKey>? comparer);

Type Parameters

TSource

The type of elements of source.

TKey

The type of the key returned by keySelector.

Parameters

source
ParallelQuery<TSource>

A sequence of values to order.

keySelector
Func<TSource,TKey>

A function to extract a key from an element.

comparer
IComparer<TKey>

An IComparer{TKey} to compare keys.

Returns

An OrderedParallelQuery{TSource} whose elements are sorted according to a key.

Exceptions

source or keySelector is a null reference (Nothing in Visual Basic).

One or more exceptions occurred during the evaluation of the query.

Remarks

In contrast to the sequential implementation, this is not a stable sort. See the remarks for OrderBy for an approach to implementing a stable sort.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0