目前在我的查询中,我说的是orderby t.Description
,我得到了:
1st street
2 burritos
Allergy
Ameripath
Application
APK THD
如何更改排序以获取此信息:
1st street
2 burritos
APK THD
Allergy
Ameripath
Application
所以现在仍然是描述,但大写字母首先出现
答案 0 :(得分:7)
您必须将有序比较器传递给OrderBy方法:
static void Main(string[] args)
{
var list = new[] {"1st street","2 burritos","Allergy","Ameripath","Application","APK THD"};
list.OrderBy(x => x, StringComparer.Ordinal).ToList().ForEach(Console.WriteLine);
}