Programming-Idioms

History of Idiom 28 > diff from v60 to v61

Edit summary for version 61 :
New Groovy implementation by user [sbglasius]

Version 60

2020-10-10, 20:34:45

Version 61

2020-10-13, 15:22:11

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
Code
items.sort { it.a }
Doc URL
https://docs.groovy-lang.org/latest/html/groovy-jdk/java/lang/Iterable.html#sort(groovy.lang.Closure)