Sorting in different culture

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
 
G

Göran Andersson

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top