如何按值(.NET 2.0)对SortDictionary进行排序?或者有没有其他替代方法?
我正在尝试像博客作者一样对标签进行排序。但是我想按使用次数对标签进行排序,而不是按名称排序?
我不得不再次问一下..为什么在ASP.NET中使用此代码无法工作?
result.Sort((first, second) => second.Value.CompareTo(first.Value));
在构建过程中出现了5个错误
var myList = new Dictionary<string, int>();
var result = new List<KeyValuePair<string, int>>(myList);
result.Sort((first, second) => second.Value.CompareTo(first.Value));
KeyedCollection
是否符合您的要求。它是IList和IDictionary之间的抽象混合体。请参阅MSDN:http://msdn.microsoft.com/en-us/library/ms132438%28VS.80%29.aspx - IAbstract