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-
You can sort SortedDictionary by value like this:
yourList.Sort(
delegate(KeyValuePair<int, double> val1,
KeyValuePair<int, double> val2)
{
return val1.Value.CompareTo(val2.Value);
}
);
The PowerCollections library has a class called OrderedMultiDictionary<TKey, TValue>
that is basically like a SortedDictionary<TKey, TValue>
but allows duplicates. When you lookup a key, you get an enumerable instead of a single value.
The library is free and you should be able to do exactly what you want with that class - store the values as the keys.