Skip to content

Instantly share code, notes, and snippets.

@duncansmart
Created March 30, 2011 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duncansmart/894091 to your computer and use it in GitHub Desktop.
Save duncansmart/894091 to your computer and use it in GitHub Desktop.
Shows effect of culture on sorting
using System;
using System.Globalization;
using System.Threading;
class Program
{
static void Main(string[] args)
{
string[] words = "chat city cabs".Split(' ');
Console.WriteLine("== " + Thread.CurrentThread.CurrentCulture + " ==");
Array.Sort(words);
foreach (string word in words)
Console.WriteLine(word);
// Switch to *traditional* Spanish (as opposed to "international")
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("es-ES_tradnl");
Console.WriteLine("== " + Thread.CurrentThread.CurrentCulture + " ==");
Array.Sort(words);
foreach (string word in words)
Console.WriteLine(word);
}
}
/* Outputs:
== en-GB ==
cabs
chat
city
== es-ES_tradnl ==
cabs
city
chat
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment