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

Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 163
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)
.ForEach(i => Console.WriteLine(i));


Comments or Responses

Login to post response