How to Use ICU Collation in Rust

Use the `icu_collator` crate to sort strings according to Unicode Collation Algorithm rules. Add the dependency to your `Cargo.toml` and initialize a collator with your target locale.

How to Use ICU Collation in Rust

Use the icu_collator crate to sort strings according to Unicode Collation Algorithm rules. Add the dependency to your Cargo.toml and initialize a collator with your target locale.

[dependencies]
icu_collator = "1.5"
icu_locid = "1.5"
use icu_collator::Collator;
use icu_locid::Locale;

fn main() -> icu_collator::Result<()> {
    let locale: Locale = "en-US".parse()?;
    let mut collator = Collator::try_new(&locale)?;
    let mut items = vec!["apple", "Banana", "cherry"];
    collator.sort(&mut items);
    println!("{:?}", items);
    Ok(())
}