Write a program in C# to print the lexicographically sorted collection

Rajnilari2015
Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 1114
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();
}

}
}

Comments or Responses

Login to post response