Logo

Programming-Idioms

History of Idiom 28 > diff from v80 to v81

Edit summary for version 81 by programming-idioms.org:
[Rust] Rustfmt: add space

Version 80

2021-09-24, 08:57:49

Version 81

2021-12-21, 00:58:06

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_by(|a,b|a.p.cmp(&b.p));
Code
items.sort_by(|a,b| a.p.cmp(&b.p));
Doc URL
https://doc.rust-lang.org/std/primitive.slice.html#method.sort_by
Doc URL
https://doc.rust-lang.org/std/primitive.slice.html#method.sort_by
Demo URL
https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=f40b0b2385f565d377c7b3bb91cc9314
Demo URL
https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=f40b0b2385f565d377c7b3bb91cc9314