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