Function cycle_sort::cycle_sort
[−]
[src]
pub fn cycle_sort<T>(slice: &mut [T]) -> usize where
T: Ord,
Sorts a slice using the elements' natural ordering and returns the number of writes made.
Examples
use cycle_sort::cycle_sort; let mut a = [1, 4, 1, 5, 9, 2]; let w = cycle_sort(&mut a); assert_eq!(a, [1, 1, 2, 4, 5, 9]); assert_eq!(w, 5);