Logo

Programming-Idioms

History of Idiom 28 > diff from v71 to v72

Edit summary for version 72 by zqwnvl:
New C# implementation by user [zqwnvl]

Version 71

2021-08-15, 23:33:38

Version 72

2021-08-16, 02:09:06

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;
Code
items.OrderBy(x => x.p)
Comments bubble
Uses the LINQ-to-objects extension method OrderBy, which is available for collections that implement IEnumerable<T>
Doc URL
https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.orderby
Demo URL
https://dotnetfiddle.net/CZnqvi