Given an collection as "dky", "amit", "sumit", "deepak". The objective is to print the lexicographically sorted collection. The below program will do so
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
new List<string>() { "dky", "amit", "sumit", "deepak" }
.OrderBy(o => o)
.ToList()
.ForEach(i => Console.WriteLine(i));
Console.ReadKey();
}
}
}