I have List<string> _wordshow
"Car", "Car", "Car", "Bird", "Sky", "Sky"
I want to sort it by each number of words going down, so the final List<string>will be
"Car",
"Sky",
"Bird
How to do it in LINQ? I don't need a score for every word
in SQL, it will be:
select word, count(1) as count1
from word
group by word
order by count1 desc, word
Answer
Another variant:
var _output = from p in _words
group p by p into g
orderby g.Count() descending, g.Key ascending
select g.Key;
source
share