gpt4 book ai didi

c# - 先按大写字母排序

转载 作者:行者123 更新时间:2023-11-30 14:10:03 26 4
gpt4 key购买 nike

目前在我的查询中我说 orderby t.Description 我得到:

1st street
2 burritos
Allergy
Ameripath
Application
APK THD

我怎样才能改变排序来得到这个:

1st street
2 burritos
APK THD
Allergy
Ameripath
Application

所以现在还是靠描述,但是大写字母在前

最佳答案

您必须将序号比较器传递给 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);
}

关于c# - 先按大写字母排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25872867/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com