Array.Sort(names, Comparer.DefaultInvariant)
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Collections;
using System.Globalization;
class Program {
static void DisplayNames(IEnumerable e) {
foreach (string s in e)
Console.Write(s + " - ");
}
static void Main(string[] args) {
string[] names = {"Alabama", "Texas", "Washington",
"Virginia", "Wisconsin", "Wyoming",
"Kentucky", "Missouri", "Utah", "Hawaii",
"Kansas", "Lousiana", "Alaska", "Arizona"};
Thread.CurrentThread.CurrentCulture = new CultureInfo("fi-FI");
Array.Sort(names);
DisplayNames(names);
Array.Sort(names, Comparer.DefaultInvariant);
Console.WriteLine("\nsorted with invariant culture...");
DisplayNames(names);
}
}
Related examples in the same category