Mega Code Archive

 
Categories / C# / LINQ
 

OrderBy

using System; using System.Collections.Generic; using System.Linq; using System.Text; public class MainClass {     public static void Main() {         string[] words = { "C", "a", "b" };         var sortedWords =             from w in words             orderby w             select w;         Console.WriteLine("The sorted list of words:");         foreach (var w in sortedWords) {             Console.WriteLine(w);         }     } }