Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

sort_by in rust

let mut vec = vec![1.1, 1.15, 5.5, 1.123, 2.0];

vec.sort_by(|a, b| a.partial_cmp(b).unwrap());

assert_eq!(vec, vec![1.1, 1.123, 1.15, 2.0, 5.5]);
 
PREVIOUS NEXT
Tagged: #rust
ADD COMMENT
Topic
Name
2+3 =