Logo

Programming-Idioms

History of Idiom 28 > diff from v38 to v39

Edit summary for version 39 by TheVTM:
[Rust] Fixed demo link

Version 38

2017-04-27, 11:02:28

Version 39

2017-04-29, 06:51:37

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);
Code
items.sort_by_key(|item| item.p);
Doc URL
https://doc.rust-lang.org/std/primitive.slice.html#method.sort_by_key
Doc URL
https://doc.rust-lang.org/std/primitive.slice.html#method.sort_by_key
Demo URL
https://is.gd/besKf4
Demo URL
https://play.rust-lang.org/?gist=561c0c2b04b7c2329d0dfb8b8413ecea&version=stable&backtrace=0