Sorting in different culture

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hi!

When we sort for example an array of char it's the numeric value for the
character that is used to decide which one is greater then the other.

But my question is if we look at other language and culture how is the
sorting done there is it based on the numeric value for
the character to decide which character is greter then another.

I mean in english if we have the character cba it could have been
implemented without using the numeric values for the character. So the
sorting of cba might have given bac.

//Tony
 
Tony said:
Hi!

When we sort for example an array of char it's the numeric value for the
character that is used to decide which one is greater then the other.

But my question is if we look at other language and culture how is the
sorting done there is it based on the numeric value for
the character to decide which character is greter then another.

I mean in english if we have the character cba it could have been
implemented without using the numeric values for the character. So the
sorting of cba might have given bac.

//Tony

If you compare characters, they will simply be compared on their numeric
value, there is no culture settings involved there.

The Char.CompareTo method is implemented as:

public int CompareTo(char value) {
return (this - value);
}

Comparing strings is a different matter. You can either compare strings
ordinally or culturally dependant. An ordinally comparison just compare
the character values, while a culturally dependant comparison has a
different order for the characters. I can group some characters together
(like "v" and "W") or ignore some characters (like "-").
 
Back
Top