Guest User

Untitled

a guest
Jun 17th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 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: Vec<i32>) -> Vec<i32> {
  5. let mut not_trees: Vec<i32> = a.iter().filter(|x| **x > 0).map(|x| *x).collect();
  6. not_trees.sort();
  7. a.into_iter().map(|x| {
  8. if x > 0 {
  9. return not_trees.remove(0);
  10. }
  11. x
  12. }).collect::<Vec<_>>()
  13. }
Add Comment
Please, Sign In to add comment