//创建字典Dictionary 对象 Dictionary<string, int> dic = new Dictionary<string, int>(); //.net 3.5 以上版本 Dictionary排序(即 linq dictionary 排序) private void DictonarySort(Dictionary<string, int> dic) { var dicSort = from objDic in dic orderby objDic.Value descending select objDic; foreach(KeyValuePair<string, int> kvp in dicSort) Response.Write(kvp.Key + ":" + kvp.Value + "<br />"); } //按降序(倒序)排列,如果想按升序(顺序)排列,只需要把变量 dicSort 右边的 descending 去掉即可。 //.net 2.0 版本 Dictionary排序 private void DictionarySort(Dictionary<string, int> dic) { if (dic.Count > 0) { List<KeyValuePair<string, int>> lst = new List<KeyValuePair<string, int>>(dic); lst.Sort(delegate(KeyValuePair<string, int> s1, KeyValuePair<string, int> s2) { return s2.Value.CompareTo(s1.Value); }); dic.Clear(); foreach (KeyValuePair<string, int> kvp in lst) Response.Write(kvp.Key + ":" + kvp.Value + "<br />"); } } //顺序排列:只需要把变量 return s2.Value.CompareTo(s1.Value); 改为 return s1.Value.CompareTo(s2.Value); 即可。