Mega Code Archive

 
Categories / C# Book / 04 LINQ
 

0455 OrderBy - Simple 1

public void Linq28() { string[] words = { "cherry", "apple", "blueberry" }; 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); } } Result The sorted list of words: apple blueberry cherry