dictionary i sırala

Ekim 15, 2008

asp.net: sorting dictionary by value in csharp

Dictionary<string, string> s = new Dictionary<string, string>();
        s.Add(“1″, “a Item”);
        s.Add(“2″, “c Item”);
        s.Add(“3″, “b Item”);        List<KeyValuePair<string, string>> myList = new
List<KeyValuePair<string, string>>(s);
        myList.Sort(
           delegate(KeyValuePair<string, string> firstPair,
KeyValuePair<string, string> nextPair)
           {
               return firstPair.Value.CompareTo(nextPair.Value);
           }
        ); 

 KAYNAK : http://starflight.be/index.php?pg=qaitem&id=112

Leave a Reply