Logo

Programming-Idioms

History of Idiom 28 > diff from v75 to v76

Edit summary for version 76 by zqwnvl:
[C#] Use shorter demo URL

Version 75

2021-08-16, 02:41:41

Version 76

2021-08-16, 03:09:45

Idiom #28 Sort by a property

Sort elements of array-like collection items in ascending order of x.p, where p is a field of the type Item of the objects in items.

Idiom #28 Sort by a property

Sort elements of array-like collection items in ascending order of x.p, where p is a field of the type Item of the objects in items.

Variables
items,x,p
Variables
items,x,p
Imports
using System.Linq;
Imports
using System.Linq;
Code
items.OrderBy(x => x.p)
Code
items.OrderBy(x => x.p)
Comments bubble
The LINQ-to-objects extension method OrderBy is available for all IEnumerable<T>
Comments bubble
The LINQ-to-objects extension method OrderBy is available for all IEnumerable<T>
Doc URL
https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.orderby
Doc URL
https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.orderby
Demo URL
https://sharplab.io/#v2:C4LgTgrgdgNAJiA1AHwAIAYAEqCMA6AGQEsoBHAbgFgAoGgSWAFMBbAbQF1MinmBnTALyYojAO6YGLDpgDewsQAoAzAEoY80QpxqNCgEwrMAXyrUAbgEMwmMI14QANsEFcevPAHkwcRmABCAJ4KAB6CAHyYwXgADiqmNABmAPa2FgDGABaYCpLMXFxQNnaOwCo0AJC4eLgAnApEcTQ0tmkpcBI89VDOseR
Demo URL
https://sharplab.io/#gist:797c5ed91ea199120783cae55b85742f