fn main() {
        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]);
      }
      
      Rust language logo

      Sort a vector of floats

      Codiga's Rust Recipes

      vector of f32 or f64

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.