Programming-Idioms

History of Idiom 28 > diff from v37 to v38

Edit summary for version 38 :
New Rust implementation by user [TheVTM]

Version 37

2017-02-23, 12:12:42

Version 38

2017-04-27, 11:02:28

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.

Code
items.sort_by_key(|item| item.p);
Doc URL
https://doc.rust-lang.org/std/primitive.slice.html#method.sort_by_key
Demo URL
https://is.gd/besKf4