[−][src]Function algos::sort::quick
pub fn quick<T: Copy + PartialOrd, C: Fn(&T, &T) -> bool>(v: &mut [T], cmp: &C)
Quick Sort: Sort v
slice according to the way you define the cmp
parameter.
This sort is unstable.
Case | Time complexity | Space complexity |
---|---|---|
Best: | Ω(nlog(n)) | |
Avrg: | Θ(nlog(n)) | |
Worst: | O(n²) | O(log(n)) |
Example
use algos::sort; let mut v = [9, 3, 5, 7, 8, 7]; // Crescent sorting sort::quick(&mut v, &|v, b| v < b);