如何按照Linq中与数组匹配的单词数对字符串列表进行排序

Flo*_*ind 5 c# linq

有没有办法按字符串数组匹配的单词数对字符串列表进行排序?

var targets = new string[] { "one", "two", "three" };
var list = new List<string>();
    list.Add("one little pony");
    list.Add("one two little pony");
    list.Add("one two three little pony");
    list.Add("little pony");
x = x.OrderByDescending(u => targets.Any(u.Contains)).ToList();
foreach(var item in list)
{
 Debug.Writeline(item);
}
Run Code Online (Sandbox Code Playgroud)

有没有办法生成输出而不使用另一个listfor循环来排序

one two three little pony
one two little pony
one little pony
little pony
Run Code Online (Sandbox Code Playgroud)

D S*_*ley 7

使用Count而不是Any:

x = x.OrderByDescending(u => targets.Count(u.Contains)).ToList();
Run Code Online (Sandbox Code Playgroud)