开发者

SortDictionary but sort by Value

开发者_如何学JAVA

How do you SortDictionary by value (.NET 2.0)? Or is there any alternative to this?

I am trying to sort Tags just like in blogger. But I want to sort the Tags by number there were used, not by name?


I have to ask again .. why this code wont work when used in ASP.NET

result.Sort((first, second) => second.Value.CompareTo(first.Value));

it throws 5 errors while building


You can use a lambda function and a List to do something like:

var myList = new Dictionary<string, int>();
var result = new List<KeyValuePair<string, int>>(myList);
result.Sort((first, second) => second.Value.CompareTo(first.Value));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜