开发者

C#: sort dictionary in descending order

开发者 https://www.devze.com 2022-12-30 01:05 出处:网络
How do I sort a keyvalue pair with descending order of their values? foreach (KeyValuePair<string, int> item in开发者_运维百科 keyvalue.OrderBy(key => key.Value))

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))
{

} 
0

精彩评论

暂无评论...
验证码 换一张
取 消