rust_dsa

Function radix_sort

Source
pub fn radix_sort(slice: &mut [usize])
Expand description

An implementation of the radix sort algorithm.

ยงExample

use rust_dsa::radix_sort;

let mut ints = [42, 14, 2, 18, 33, 19, 21, 38];
radix_sort(&mut ints);
assert_eq!(&ints, &[2, 14, 18, 19, 21, 33, 38, 42]);

let mut random: Vec<_> = (0..100_000).map(|_| rand::random()).collect();
radix_sort(&mut random);
for i in 1..random.len() {
    assert!(random[i - 1] <= random[i]);
}