var listExample = new List<string>(){ "banana", "apple", "lemon", "orange",
"cherry", "pear", "??????", "?????", "?????", "?????", "????????", "?????" };
listExample = listExample.OrderBy(x => x).ToList();
Run Code Online (Sandbox Code Playgroud)
结果是
{ "apple", "banana", "cherry", "lemon", "orange", "pear", "????????", "?????", "?????", "?????", "?????", "??????" }
Run Code Online (Sandbox Code Playgroud)
但需要俄罗斯的第一个订单然后像这样的英语
{ "????????", "?????", "?????", "?????", "?????", "??????", "apple", "banana", "cherry", "lemon", "orange", "pear" }
Run Code Online (Sandbox Code Playgroud)
如何使用OrderBy获得该结果?
如果工作正常,您可以使用订单检查latin.
下面的代码返回所需的输出,它检查单词是否为IsCyrillic.
var listExample = new List<string>(){ "banana", "apple", "lemon", "orange", "cherry",
"pear", "??????", "?????", "?????", "?????", "????????", "?????" };
var result = listExample.OrderBy(x => x)
.Select(x => new {val = x, isCyrillic = Regex.IsMatch(x, @"\p{IsCyrillic}")})
.OrderBy(x => !x.isCyrillic).Select(x => x.val);
foreach (var str in result)
{
Console.WriteLine(str);
}
Run Code Online (Sandbox Code Playgroud)
检查这个小提琴的完整代码 - https://dotnetfiddle.net/9o4FJt
上述程序的输出是
苹果香蕉樱桃柠檬橙梨苹果апана