I have strings associated with some double value. I need to be able to sort them easily by the value and to easily get the strings as some kind of list. There could be 100k+ of those pairs.
So, my question is whether I should use a Dictionary with strings as keys and doubles as values or a List of KeyValuePairs with the same keys and values?
In case of the dictionary it's easy to get the keys as a list via
dict.Keys.toList()
and in case of the list it's easy to sort by value via
list.Sort(delegate(KeyValuePair x, KeyValuePair y) { return y.Value.CompareTo(x.Value); })
.
I haven't found a way to do both though. What do you recommend?