I'm currently making a library that at one point requires me to sort a list of paths. These paths must be sorted in a somewhat "natural" order, which means that
[ 'a', 'e', 'E', 'é', 'ä' ] should result in something like
[ 'a', 'ä', 'e', 'E', 'é' ] (the result may not be exactly like that, but it's the idea), which is not the result you get by using the traditional comparison methods which only compare codepoints values.
I've searched for a few hours now a library that handles that work, as it's really complicated with latin alphabet's accents and case alone, so I don't imagine what it's like with other languages.
My question is: is there any library that allows to do this? I've seen several mentions of the "Unicode Collation" algorithm, but no concrete implementation of it. ICU seems to have the solution to the problem too but there isn't any good bindings library (either the bindings are not developed enough, or they don't allow to perform simple character comparisons). There is also no way to get a simple comparison from the system apparently.
I've also found the
unicode-normalization library, but this one is pretty complicated as it performs (de)composition on graphemes which is a lot more complicated.
.localeCompare() would be absolutely perfect but I can't find anything like that
So, does anyone have an idea of what library I could use?
NOTE : I'm working on a crate where I can't use any unsafe code, and I would really like to avoid calling a command-line tool.
Thanks in advance for your asnwers