Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

rust sort vec of f64

// create Vec<f64>
let mut v : Vec<f64> = Vec::from([1.5,3.3,5.1,4.2,2.4]);

// sort Vec
v.as_mut_slice().sort_by(|a, b| a.partial_cmp(b).unwrap());

// print result
println!("{:?}",v);

// ------------------------------------------------------------- //
// Output:
// 
// [1.5, 2.4, 3.3, 4.2, 5.1]
 
PREVIOUS NEXT
Tagged: #rust #sort #vec
ADD COMMENT
Topic
Name
2+8 =