How to sort a vector in Rust? Ask Question

How to sort a vector in Rust? Ask Question

What is the currently recommended method for sorting values in a vector?

ベストアンサー1

A mutable slice of elements with a total ordering has a sort method.

Because Vec<T> implements DerefMut<[T]>, you can call this method directly on a vector, so vector.sort() works.

おすすめ記事