Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

sort a vec rust

fn main() {
    let mut v: [f32; 5] = [5.0, 4.0, 1.0, 3.0, 2.0];
    v.sort_by(|a, b| a.partial_cmp(b).unwrap());
    assert!(v == [1.0, 2.0, 3.0, 4.0, 5.0]);
}
Source by users.rust-lang.org #
 
PREVIOUS NEXT
Tagged: #sort #rust
ADD COMMENT
Topic
Name
3+8 =