0
客户的字典和相关数据(例如MoneySpent),并想只返回客户的排序列表。 我想通了迄今唯一的解决办法是这样的:更好的办法排序字典并获得钥匙,我只有
CustomerData<Customer, int> //the value here is the money spent
List<KeyValuePair<Customer, int>> sortedListByValue = CustomerData.OrderByDescending(s => s.Value).ToList();
然后只是要通过量清单,并获得钥匙。但是,我确信有一个更简单的方法,并会很乐意提供建议。
什么是'CustomerData'?你能在你的代码中显示吗? – CodingYoshi
一种替代的解决方案,以接受的答案(当然,相同的真,但与其他语法),与查询语法:'VAR排序=(从CustomerData的OrderBy kv.Value千伏降序选择kv.Value).ToList(); ' –