CKTIS / C#
Enumerable.OrderBy: practical reference
Enumerable.OrderBy: practical reference: During enumeration, this deferred operation buffers the whole source and performs a stable ascending sort by key.
Version: .NET LINQ; verified on .NET 10.0.14
Syntax
source.OrderBy(/* overload-specific arguments */)During enumeration, this deferred operation buffers the whole source and performs a stable ascending sort by key.
Use it to establish ordering; add subsequent keys with ThenBy.
A new OrderBy after an earlier sort replaces key priority. Sorting needs memory and yields nothing before the source is read.
An empty source yields an empty result. A null comparer selects Comparer.Default; only a null source or keySelector causes ArgumentNullException.
The complete program actually uses Enumerable.OrderBy; its exact expected stdout is 1,2,3.
Examples
using System;
using System.Collections.Generic;
using System.Linq;
Console.WriteLine(string.Join(",", new[] { 3, 1, 2 }.OrderBy(value => value)));
Result
1,2,3
The complete program actually uses `Enumerable.OrderBy`; its exact expected stdout is `1,2,3`.