I have a SortedDictionary whose value is a List of objects. I want to sort the value(the list) of each key by a given property of the object. In the current situation, I need to sort the list first by objects's lastname, then by firstname. I tried LINQ and it got nasty pretty fast without producing the result.
EDIT:
I have the following structure:
public class Person { private string firstName; private string lastName; ... } I need the dictionary sorted by the key. However, I need every List to be sorted first by Person's lastName, then by firstName.
var dict = new SortedDictionary<string, List<Person>>(); I didn't provide code for the sorting because i can't get it to work. That's why I seek help.
SortedDictionaryis sorted on the key not on the values. Why don't you sort the lists before you add them to the dictionary?SortedSet<Person>.