using System; class MainClass { public static void Main() { char[] charArray = {'w', 'e', 'l', 'c', 'o', 'm', 'e'}; Array.Sort(charArray); // sort the elements Console.WriteLine("Sorted charArray:"); for (int i = 0; i < charArray.Length; i++) { Console.WriteLine("charArray[" + i + "] = " + charArray[i]); } } }
Sorted charArray: charArray[0] = c charArray[1] = e charArray[2] = e charArray[3] = l charArray[4] = m charArray[5] = o charArray[6] = w