Skip to main content
Correction + Reaction to comments
Source Link
mtwde
  • 14.3k
  • 2
  • 35
  • 61

To cover everythingLast and least: The 4th sorting method

To cover everything: The 4th sorting method

Last and least: The 4th sorting method

Correction + Reaction to comments
Source Link
mtwde
  • 14.3k
  • 2
  • 35
  • 61
  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. 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.It's Asas 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 DIN 5007-1) var. 1.
    

Also ... one of my professors once said: "The first thing I do before coding is searching the internet if there is already a solution." And as @RHa and @cbeleites said in the comments there are solutions (C, Java, PHP, etc.), so unless you insist ... use one of them and you only have to worry about choosing the right locale (and looking up which sorting rules they follow).

To cover everything: The 4th sorting method

As I mentioned ealier there is a 4th (horrible) solution. German Wikipedia describes it as

Gleichordnung von Grundbuchstaben, Doppelbuchstaben und Umlaut, wenn Doppelbuchstabe wie Umlaut gesprochen wird. Mull wird wie Muell oder Müll sortiert. Duell dagegen zwischen Duden und Dugast.

To explain it in English I would like to quote @FabioTurati from the comments

It says that an approach is treating plain letters, double letters and Umlauts the same way, but only when the double letters are pronounced as an Umlaut. For example, "Mull", "Muell" and "Müll" are treated the same way (note that Mull and Müll are different words!), and the "ue" in Muell here is a way to avoid typing "ü". In other cases, the letters "ue" are pronounced separately: a "u" followed by an "e", for example in "Duell", which is why Duell is placed between Duden and Dugast.

Why is this a problem?

Consider it from the other point of view: if you find a word containing "ue", how do you treat it? For Muell you should pretend the "e" is not there, and treat it as "Mull". For "Duell", doing it would lead to "Dull", which would be sorted after "Dugast", which would be wrong. So, to know how to sort words you need to have some more info (that is, how they are pronounced), which a sorting algorithm normally doesn't have. That's why this approach is troublesome!

  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. 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).
    

Also ... one of my professors once said: "The first thing I do before coding is searching the internet if there is already a solution." And as @RHa and @cbeleites said in the comments there are solutions (C, Java, PHP, etc.), so unless you insist ... use one of them and you only have to worry about choosing the right locale.

  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. 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)
    
    It's 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 DIN 5007-1 var. 1.
    

Also ... one of my professors once said: "The first thing I do before coding is searching the internet if there is already a solution." And as @RHa and @cbeleites said in the comments there are solutions (C, Java, PHP, etc.), so unless you insist ... use one of them and you only have to worry about choosing the right locale (and looking up which sorting rules they follow).

To cover everything: The 4th sorting method

As I mentioned ealier there is a 4th (horrible) solution. German Wikipedia describes it as

Gleichordnung von Grundbuchstaben, Doppelbuchstaben und Umlaut, wenn Doppelbuchstabe wie Umlaut gesprochen wird. Mull wird wie Muell oder Müll sortiert. Duell dagegen zwischen Duden und Dugast.

To explain it in English I would like to quote @FabioTurati from the comments

It says that an approach is treating plain letters, double letters and Umlauts the same way, but only when the double letters are pronounced as an Umlaut. For example, "Mull", "Muell" and "Müll" are treated the same way (note that Mull and Müll are different words!), and the "ue" in Muell here is a way to avoid typing "ü". In other cases, the letters "ue" are pronounced separately: a "u" followed by an "e", for example in "Duell", which is why Duell is placed between Duden and Dugast.

Why is this a problem?

Consider it from the other point of view: if you find a word containing "ue", how do you treat it? For Muell you should pretend the "e" is not there, and treat it as "Mull". For "Duell", doing it would lead to "Dull", which would be sorted after "Dugast", which would be wrong. So, to know how to sort words you need to have some more info (that is, how they are pronounced), which a sorting algorithm normally doesn't have. That's why this approach is troublesome!

formatting according to SO/Markdown rules
Source Link

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).

  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. 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:

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:

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).

For further information take a look at

European ordering rules (EOR / EN 13710)

Unicode collation algorithm

ISO 14651 (download)

One very last comment:

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:

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. 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

One very last comment:

added 1774 characters in body - reaction to comments
Source Link
mtwde
  • 14.3k
  • 2
  • 35
  • 61
Loading
added 399 characters in body
Source Link
mtwde
  • 14.3k
  • 2
  • 35
  • 61
Loading
Added Link & Correction + Reaction to comments
Source Link
mtwde
  • 14.3k
  • 2
  • 35
  • 61
Loading
added 41 characters in body
Source Link
mtwde
  • 14.3k
  • 2
  • 35
  • 61
Loading
Source Link
mtwde
  • 14.3k
  • 2
  • 35
  • 61
Loading