.NET SortedDictionary But Sorted By Values

前端 未结 2 1848
我在风中等你
我在风中等你 2020-12-20 17:02

I need a data structure that acts like a SortedDictionary but is sorted based on the values rather than the keys. I need it to take about 1-

2条回答
  •  生来不讨喜
    2020-12-20 17:30

    You can sort SortedDictionary by value like this:

    yourList.Sort(
        delegate(KeyValuePair val1,
        KeyValuePair val2)
        {
            return val1.Value.CompareTo(val2.Value);
        }
    );
    

提交回复
热议问题