What is the ‘best’ way to sort (or iterate) over a StringDictionary in order of Value (not Key)
E.g. Key – Value
- 1 – X label
- 2 – A label
- 3 – Other label
would give
- 2 – A label
- 3 – Other label
- 1 – X label
EDIT – I meant to say “using .NET 2.0 features”. Sorry, me bad…
Use LINQ:
If you are restricted to C# 2.0 features, use this:
Note:
If you are using a StringDictionary instead of Dictionary, check out Anthony’s solution.