Sorting is not returning a vector

I just need to sort a vector, and It's returning '()', So I can't use the it, Here is the code:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=cc54e3f9824604fe1cd60537792200a1

sort_unstable modifies the given vector.
If you want to keep the unsorted one, clone it first, then sort that clone.

let mut vs = v.clone();
vs.sort_unstable();
1 Like

I have the exact same error when I clone it.

Don't assign the result (there is none), just use the vector after you sort it in-place.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.