This is for. NET version is too low to sort the way, not how to use, record a bit;
First, create a dictionary Dictionary object
If the Dictionary is a website page traffic, key is the page name, the value of the page is the number of visits, because of the page's access to the statistics, so can not use int as key, only with the page name, create Dictionary object and add data code as follows:
dictionary<string,int> dic =Newdictionary<string,int>(); Dic. ADD ("index.html", -); Dic. ADD ("product.html", -); Dic. ADD ("aboutus.html",4); Dic. ADD ("online.aspx", A); Dic. ADD ("news.aspx", -);
Ii.. NET 2.0 version dictionary sorting
list<keyvaluepair<stringintnew list<keyvaluepair<stringint >>(DIC);
Flashback arrangement: Simply swap the variable s2 and S1 for an example: return S1.Value.CompareTo (S2. Value);
Sorting is now in order
lst. Sort (delegate(keyvaluepair<stringint> S1, keyvaluepair<string int> s2) { return s2.Value.CompareTo (S1. Value); }); Dic. Clear ();
Iii.. NET 3.5 or later dictionary sorting (that is, LINQ dictionary sorting)
Sort by using LINQ
var from inch by Select objdic;
output to use this output: foreach (keyvaluepair<stringintin ": " " <br/>");}
C # Dictionary dictionary sort (sequential, reverse)