std-method
slice::sort_unstable
Sort in place using Ord without preserving the relative order of equal elements. Choose it only when equal-key order is unimportant. Expected stdout (not executed): [3, 3, 7, 9] Common mistake: Assuming an unstable sort produces unsorted data, or relying on equal-key order.
Formal Syntax & Structure
rust syntaxrust
slice.sort_unstable()Working Example
Example Snippetrust
fn main() { let mut scores = [7, 3, 9, 3]; scores.sort_unstable(); println!("{scores:?}");}