using System;
using System.Collections.Generic;
using System.Linq;
namespace TestCalculator
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("/* life runs on code */");
//Dictionary.
var dictionary = new Dictionary<string, int>(5);
dictionary.Add("Anil", 1);
dictionary.Add("Amol", 0);
dictionary.Add("Pravin Singh", 5);
dictionary.Add("Jeet", 3);
dictionary.Add("Sadhana", 2);
//Using Order by values.
//LINQ to specify sorting by value.
var sorts = from pair in dictionary
orderby pair.Value ascending
select pair;
// Display results.
foreach (var sort in sorts)
{
Console.WriteLine("{0}: {1}", sort.Key, sort.Value);
}
}
}
}In this example, we used orderby clause of LINQ to sort the Dictionary.
