I’ve got the following code to extract keywords from a string:
var results = text.Split(new char[]{' ',',','.','!','?','_',':',';','/','(',')','\n','\r','-','*','"','/','\\','$','%','+','-','='}) // default split by whitespace
.GroupBy(str => str) // group words by the value
.Select(g => new
{
str = g.Key, // the value
count = g.Count() // the count of that value
});
Now I need to add OrderByDescending to it, but not sure where to place it.
.GroupBy(str => str).OrderByDescending(count => count) yielded incorrect results. How to make it right?
You can add it after the select.