Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

how to sort a dictionary by value in c#

using System.Linq.Enumerable;
...
List<KeyValuePair<string, string>> myList = aDictionary.ToList();

myList.Sort(
    delegate(KeyValuePair<string, string> pair1,
    KeyValuePair<string, string> pair2)
    {
        return pair1.Value.CompareTo(pair2.Value);
    }
);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sort #dictionary
ADD COMMENT
Topic
Name
2+2 =