snippetrustCritical
How to sort a vector in Rust?
Viewed 0 times
rusthowvectorsort
Problem
What is the currently recommended method for sorting values in a vector?
Solution
A mutable slice of elements with a total ordering has a
Because
sort method.Because
Vec implements DerefMut, you can call this method directly on a vector, so vector.sort() works.Context
Stack Overflow Q#26836488, score: 159
Revisions (0)
No revisions yet.