Short answer:
Short answer: Take a look at MySQL and different character-collations. Choose one and follow its rules. Or as @RHa and @cbeleites suggest find a library that provides locale-dependent sorting.
Long answer:
Long answer:
There are 3 different solutions for your problem (actually there are 4, but believe me, you don't want to realize the 4th ;) )
1) Rewrite every Umlaut to its base (German dictionary rules - DIN 5007-1 var. 1)
Every Umlaut and Diacritic results in the same char.
e.g.
áàâäã = a
ß = ss
and so on.
Sort them.
2) Rewrite every Umlaut by adding an e, diacritics are removed (German phone book rules - DIN 5007-1 var. 2)
ä = ae
áàâã = a
ü = ue
ß = ss
Sort them.
3 a) Umlaute are new chars added to the alphabet (Swedish/Finnish collation rules)
Every Umlaut and å are treated like new chars, which are added after the z of the alphabet. Other chars with diacretics are converted to their base.
So sort like
aáàâãbcd [...] xyzåäü
3 b) Umlaute are new chars added to the alphabet (Austrian phone book order - kudos to @rexkogitans from the comments)
As 3a), but Umlaute and chars with Diacretics are appended to their base characters.
aäáà [...] bcdeèé [...] uü ...
But watch out, wiki says this is true for the Austrian White Pages, but the Austrian Yellow Pages are sorted like 1).
Rewrite every Umlaut to its base (German dictionary rules - DIN 5007-1 var. 1)
Every Umlaut and Diacritic results in the same char.
e.g.
áàâäã = a
ß = ss
and so on.
Sort them.
Rewrite every Umlaut by adding an e, diacritics are removed (German phone book rules - DIN 5007-1 var. 2)
ä = ae
áàâã = a
ü = ue
ß = ss
Sort them.
-
1. Umlaute are new chars added to the alphabet ([Swedish][2]/Finnish collation rules)
Every Umlaut and *å* are treated like new chars, which are added after the z of the alphabet. Other chars with diacretics are converted to their base.
So sort like
> aáàâãbcd [...] xyzåäü
2. Umlaute are new chars added to the alphabet ([Austrian phone book order][3] - kudos to @rexkogitans from the comments)
3. As 3.1., but Umlaute and chars with Diacretics are appended to their base characters.
> aäáà [...] bcdeèé [...] uü ...
But watch out, wiki says this is true for the Austrian White Pages, but the Austrian Yellow Pages are sorted like 1).
For further information take a look at
European ordering rules (EOR / EN 13710)
Unicode collation algorithm
ISO 14651 (download)
One very last comment:
One very last comment: