DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
How To Sort String Array Using LINQ In C#
A string[] array and use a LINQ query expression to order its contents alphabetically. Note that we are ordering the strings, not the letters in the strings.
using System;
using System.Linq;
class Program
{
static void Main()
{
string[] a = new string[] {"Indonesian","Korean","Japanese","English","German"};
var sort = from s in a orderby s select s;
foreach (string c in sort)
{
Console.WriteLine(c);
}
}
}
/*OUTPUT
English
German
Indonesian
Japanese
Korean
*/
<a href="http://www.java-forums.org/blogs/eclipse-ide/"><strong>Eclipse IDE</strong></a> and <a href="http://www.java-forums.org/blogs/eclipse/"><strong>Eclipse</strong></a>





