tags:

views:

395

answers:

1

How do I sort a keyvalue pair with descending order of their values?

foreach (KeyValuePair<string, int> item in keyvalue.OrderBy(key => key.Value))
            {
            } 
+9  A: 

Use OrderByDescending instead of OrderBy.

foreach (var item in keyvalue.OrderByDescending(key => key.Value))
{

} 
Adam Robinson
Thanks. It Worked.
Yang