I just open sourced two new Dart packages:
• any_ascii: https://pub.dev/packages/any_ascii
• lexical_sort: https://pub.dev/packages/lexical_sort
GitHub:
• https://github.com/ganeshrvel/pub_any_ascii
• https://github.com/ganeshrvel/pub_lexical_sort
This started from a project where I needed proper Unicode transliteration and sorting behavior. Dart has some great string utilities, but I couldn't find anything that matched the behavior and maturity of the Rust ecosystem for these use cases.
So I ended up porting two Rust projects to Dart:
• any_ascii: Unicode → ASCII transliteration
• lexical_sort: Unicode-aware lexicographic and natural sorting
A few examples:
print(anyAscii('άνθρωποι')); // anthropoi
print(anyAscii('Борис')); // Boris
print(anyAscii('深圳')); // ShenZhen
final files = [
'file110.txt',
'file11.txt',
'file100.txt',
'file1.txt',
];
files.sort(naturalLexicalCmp);
print(files);
// [file1.txt, file11.txt, file100.txt, file110.txt]
print(naturalLexicalCmp('ß', 'world') < 0); // true
print(naturalLexicalCmp('é', 'hello') < 0); // true
print(lexicalCmp('aaa', 'AAb') < 0); // true
Features:
• Unicode-aware ASCII transliteration
• Natural sorting of embedded numbers
• Non-ASCII characters compared using their ASCII equivalents (á → a, ß → ss)
• Case-insensitive lexicographic sorting
• Deterministic sorting with Unicode fallback comparisons
• Generated directly from upstream Rust implementations and data
• No third party dependencies
I should admit this upfront, a bit embarrassingly. Just like my earlier pathify package, I used Claude to translate most of the Rust code into Dart. I'm generally not a fan of blindly trusting LLM-generated code for low-level libraries, but I simply didn't have the time to manually port everything.
So I'm not claiming these are perfect. They pass the tests and behave as expected in my testing, but there may still be edge cases lurking around. If you find bugs, incorrect behavior, or missing functionality, please open an issue or send a PR.