Sort using a custom comparator: Difference between revisions

→‎{{header|Rust}}: Update to use Ordering::then method
(Add min)
(→‎{{header|Rust}}: Update to use Ordering::then method)
Line 2,894:
fn main() {
let mut words = ["Here", "are", "some", "sample", "strings", "to", "be", "sorted"];
words.sort_by(|l, r| if lOrd::cmp(&r.len(), == r&l.len()).then(Ord::cmp(l, {r)));
l.cmp(&r)
} else {
r.len().cmp(&l.len())
});
println!("{:?}", words);
}
Anonymous user