So basically I have this:
let mut sortedNumbers = numbers.clone();
sortedNumbers.sort_by(|a, b| b.rational.cmp(&a.rational));
Where numbers is a &[..]
I want to somehow sort the sortedNumbers vector, but the reference is not mutable. Any ideas?
If
numbersis a&[T], thennumbers.clone()is also a&[T], referring to the same array. What you want isnumbers.to_vec()ornumbers.to_owned(), which give you aVec<T>, which you can then modify.