dogweather / naturally

Natural sort algorithm
MIT License
87 stars 20 forks source link

Umlauts not supported #20

Open gucki opened 9 years ago

gucki commented 9 years ago

Is:

Naturally.sort %w(Birnen Äpfel Zitronen)
=> ["Birnen", "Zitronen", "Äpfel"]

Correct would be:

Naturally.sort %w(Birnen Äpfel Zitronen)
=> ["Äpfel", "Birnen", "Zitronen"]
dogweather commented 9 years ago

That's very interesting. I don't know offhand how Ruby handles this, but some systems like mysql allow a language/country sort "collation" to be set.

Hmm... here's a somewhat outdated Ruby library for that purpose. So it looks like we need to figure out if this is something that should be in this gem, or something we can do in the Ruby environment.

chocolateboy commented 8 years ago
aried3r commented 7 years ago

This JavaScript library allows setting a custom alphabet.

I guess this wouldn't solve all cases, but a good portion of it, especially if it's optional. In case people need more than one language they'd have to roll it themselves, but maybe that's a tradeoff between having to maintain different alphabets or collations within this gem and not having that option at all.

dogweather commented 5 years ago

The transliterate strategy is interesting: I guess the implication is that German sort order follows the transliterated spelling, or it's at least close to it? (I'm fluent in German, but not familiar with the alpha ordering.)

dogweather commented 5 years ago

It looks like there's a Duden way and a telephone book way: https://german.stackexchange.com/a/1798/1106

Telephone book = transliteration Duden = pretend like the diacritical doesn't exist. Weird.