List<string> 去重复 并且出现次数最多的排前面
List<string> str = new List<string> {"a","b","a","a","c","b","c","c","d","c"};
var tt = from ps in str
group ps by ps
into g
select new {g.Key,num=g.Count()};
var newstr = tt.OrderByDescending(p => p.num);
foreach (var item in newstr)
{
Console.WriteLine(item.Key);
}
var tt = from ps in str
group ps by ps
into g
select new {g.Key,num=g.Count()};
var newstr = tt.OrderByDescending(p => p.num);
foreach (var item in newstr)
{
Console.WriteLine(item.Key);
}