rdst

Crates.io

rdst is a flexible native Rust implementation of unstable radix sort.

Usage

In the simplest case, you can use this sort by simply calling my_vec.radix_sort_unstable(). If you have a custom type to sort, you may need to implement RadixKey for that type.

Default Implementations

RadixKey is implemented for Vec of the following types out-of-the-box:

Implementing RadixKey

To be able to sort custom types, implement RadixKey as below.

Note that this also allows you to implement radix keys that span multiple values.

```rust impl RadixKey for u16 { const LEVELS: usize = 2;

#[inline]
fn get_level(&self, level: usize) -> u8 {
    let b = self.to_le_bytes();

    match level {
        0 => b[1],
        _ => b[0],
    }
}

} ```

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.