How do I sort a keyvalue pair with descending order of their values?
foreach (KeyValuePair<string, int> item in开发者_运维百科 keyvalue.OrderBy(key => key.Value))
{
}
Use OrderByDescending
instead of OrderBy
.
foreach (var item in keyvalue.OrderByDescending(key => key.Value))
{
}
精彩评论