[][src]Function buldak::radix::sort

pub fn sort<T>(array: &mut [T], radix: usize, digits_max: usize) where
    T: TryInto<isize> + TryFrom<isize> + Clone,
    <T as TryInto<isize>>::Error: Debug

Sort in ascending order using a radix sort algorithm.

The parameter 'radix' is ​​the base on which to sort. If you want decimal based sorting, you can pass 10.

The parameter 'digits_max' is the maximum number of digits in the array. For example, if the maximum number in the array does not exceed 9999, you can pass 4. Any value beyond this number will cause an error.

use buldak::radix;

let mut nums = [1, 4, 2, 3, 5, 111, -33, 234, 21, 13];
radix::sort(&mut nums, 10, 4);
assert_eq!(nums, [-33, 1, 2, 3, 4, 5, 13, 21, 111, 234]);