Created
March 30, 2011 09:00
-
-
Save duncansmart/894091 to your computer and use it in GitHub Desktop.
Shows effect of culture on sorting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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