views:

185

answers:

1

Hi,

i have a list of country names. Now i want to sort them alphabeticly, with the users culture in mind. I have the 4 scandinavian cultures norway, sweden, danmark en finland.

For sweden, the Ö (O with two dots if it's not printed correctly) must appear at the end, after the Z, but for danmark it's just the letter O, so it must appear after the N.

I already did some work to create an O for the Ö for danmark but keep it an Ö for Sweden.

But List.sort doesn't have an overload for a cultureinfo, only for a stringcomparer. But in the stringcomparer a can't provide a cultureinfo?

Michel

+3  A: 

If you are using C# you can try this

List<string> s = new List<string>();
            s.Sort(delegate(string item1, string item2) { return String.Compare(item1,item2, false, new CultureInfo("")); });
astander
Thanks, that did the trick.Maybe this is a bit off topic, but the sorting wht the cultureinfo 'sv-SE' gives me the Ø after the Z, and as far as i can find the Ø is not a separate letter in the swedish alphabet.
Michel