Logo

Programming-Idioms

History of Idiom 28 > diff from v78 to v79

Edit summary for version 79 by zqwnvl:
New VB implementation by user [zqwnvl]

Version 78

2021-08-16, 03:37:09

Version 79

2021-08-16, 03:37:16

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
Imports System.Collections.Generic
Code
System.Array.Sort(items, Comparer(Of Item).Create(Function(a, b) a.p - b.p))
Comments bubble
Sorts the array items in-place.
Doc URL
https://docs.microsoft.com/en-us/dotnet/api/system.array.sort
Demo URL
https://sharplab.io/#gist:91d5b00e9128e39e3f82378f127991bc