Guest User

Untitled

a guest
Jun 17th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. // This function is supposed to sort all non negative numbers in the indeces
  2. // that all non negative numbers are originally found
  3.  
  4. fn sortByHeight(a: &mut Vec<i32>) {
  5. let mut not_negative: Vec<i32> = a.clone();
  6. not_negative.retain(|x| *x > 0);
  7. not_negative.sort();
  8. not_negative.reverse();
  9.  
  10. for x in a {
  11. if *x > 0 {
  12. *x = not_negative.pop().unwrap();
  13. }
  14. }
  15. }
  16.  
  17. fn main() {}
Add Comment
Please, Sign In to add comment