fn sorted<T: Clone, F>(x: Vec<T>, cmp: F) -> Vec<T>
  where F: FnMut(&T, &T) -> Ordering
{
  let mut y = x.clone();
  y.sort_by(cmp);
  return y;
}
/* Rust's sort_by mutates the vector, we want to return a copy.
 *
 * Note that the vector's element type must also be cloneable. */
Rust's sort_by mutates the vector, we want to return a copy.
Note that the vector's element type must also be cloneable.
Rust ' s sort_by mutates the vector we want to return a copy . Note that the vector ' s element type must also be cloneable .
fn sorted<T: Clone, F>(x: Vec<T>, cmp: F) -> Vec<T>
  where F: FnMut(&T, &T) -> Ordering
{
  let mut y = x.clone();
  y.sort_by(cmp);
  return y;
}
fn sorted < T : Clone , F > ( x : Vec < T > , cmp : F ) -> Vec < T > where F : FnMut ( & T , & T ) -> Ordering { let mut y = x . clone ( ) ; y . sort_by ( cmp ) ; return y ; }
Rust's sort_by mutates the vector, we want to return a copy.
Rust ' s sort_by mutates the vector we want to return a copy .
x
Vec<T>
cmp
F
x
Vec<T>
cmp
F