Programming-Idioms

History of Idiom 28 > diff from v61 to v62

Edit summary for version 62 :
[Groovy] To use x and p

Version 61

2020-10-13, 15:22:11

Version 62

2020-10-13, 15:23:32

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