In the below example, how to return row have minimum value at element(0) of dictionary?
Dictionary> dictSource2 = new Dictionary>
{
{ 1, new List { "5", "Programmers" }},
{ 2, new List { "12", "Testers" }},
{ 3, new List { "2", "Designers" }},
};
I want to return the following data from above dictionary-
"2", "Designers"
I have written below:
string sminValue= dictSource.Min(pair => pair.Value.ElementAt(0))
But it returns the incorrect results.Note, my solution woks fine when value at ElementAt(0) has zero records. Can anyone guide here?

Jaipal ReddyRank #588 · 4.1K reputationPosted Jun 22, 2015, 2:19 AM EDT
min(d.items(), key=lambda x: x[1])[0]Jaipal ReddyRank #588 · 4.1K reputationPosted Jun 22, 2015, 2:21 AM EDT
Jaipal ReddyRank #588 · 4.1K reputationPosted Jun 22, 2015, 2:36 AM EDT
the following works exactly what you expect - Dictionary dictSource2 = new Dictionary(); dictSource2.Add("Programmers", 5); dictSource2.Add("Testers", 12); dictSource2.Add("Designers", 2); var min = dictSource2.Aggregate((l, r) => l.Value < r.Value ? l : r).Key; Console.WriteLine(min);Sakthikumar ThanavelRank #1,235 · 1.4K reputationPosted Jun 24, 2015, 11:03 AM EDT