C# sort dictionary with linq

前端 未结 4 942
夕颜
夕颜 2021-01-02 00:43

I have a dictionary in C#:

public Dictionary

And I would like to get my result in to a generic list:

Li         


        
4条回答
  •  感动是毒
    2021-01-02 01:05

    Try this

    List productList = dictionary.OrderByDescending(x => x.Value).Select(x => x.Key).ToList();
    

提交回复
热议问题