c# dictionary,list排序

Dictionary Key排序

Dictionary<string, string> dct= new Dictionary<string, string>();

Dictionary<string, string> dctNew = dct.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value);

 

list Key排序

Public class student{

    public int grade
    {
        set;
        get;
    }

    public int age
    {
        set;
        get;
    }

    public string name
    {
        set;
        get;
    }
}  

List<student> students = new List<student>();
students.OrderBy(x=>x.grade).ThenBy(x=>x.age); 

  

posted @ 2019-01-31 12:03  翻白眼的哈士奇  阅读(323)  评论(0编辑  收藏  举报