Sorting a List of Dictionary items in C#
I know this is super nerdy, and totally irrelevant to most, but I had to share the most exciting moment of my day (so far).
This works exactly as it looks like it should.
List<Dictionary<string, string>> friendList =
new List<Dictionary<string, string>>();
friendList.Sort(
(first, second) =>
{ return first["name"].CompareTo(second["name"]); }
);
This’ll work too, but I’m not totally comfortable with the syntax yet.
var sortedList = (from f in friendList orderby f["name"] select f);