Logo

Programming-Idioms

History of Idiom 28 > diff from v12 to v13

Edit summary for version 13 by :

Version 12

2015-08-20, 16:31:32

Version 13

2015-08-21, 16:27:51

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 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 type Item of the objects in items.

Code
items.sort((a, b) => Comparable.compare(a.p, b.p));
Demo URL
https://dartpad.dartlang.org/e257952adde1efa570c3