names.Sort((a, b) => a.name.CompareTo(b.name));
using System; using System.Collections.Generic; using System.Globalization; class Program { static void Main() { List<string> names = new List<string> { "张三", "李四", "王五", "赵六" }; // 获取中文排序规则 CompareInfo compareInfo = CultureInfo.GetCultureInfo("zh-CN").CompareInfo; // 对名字列表按姓氏进行排序 names.Sort((x, y) => compareInfo.Compare(x, 0, 1, y, 0, 1)); // 输出排序后的名字 foreach (var name in names) { Console.WriteLine(name); } } }
标签:name,C#,System,姓氏,names,using,排序 From: https://www.cnblogs.com/shy1766IT/p/17908952.html