Array.Sort(names, Comparer.DefaultInvariant) : Array « System « C# / C Sharp by API






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

1.Array.AsReadOnly
2.Array.BinarySearch
3.Array.Clone
4.Array.ConvertAll
5.Array.Copy
6.Array.CopyTo
7.Array.Count
8.Array.CreateInstance
9.Array.Exists
10.Array.Find
11.Array.FindAll
12.Array.ForEach
13.Array.GetEnumerator()
14.Array.GetLength()
15.Array.GetLowerbound
16.Array.GetUpperBound
17.Array.IndexOf
18.Array.LastIndexOf
19.Array.Length
20.Array.Rank
21.Array.Resize
22.Array.Reverse
23.Array.Reverse(nums, 1, 3)
24.Array.Sort
25.Array.SyncRoot