OrderBy - Simple 1

Query
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);
}
}
Lambda Expression
public void Linq28()
{
string[] words = { "cherry", "apple", "blueberry" };

var sortedWords = words.OrderBy(word => word);

Console.WriteLine("The sorted list of words:");
foreach (var w in sortedWords)
{
Console.WriteLine(w);
}
}
Output
The sorted list of words:
apple
blueberry
cherry
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +