當某一數值相等,接着安照拼音排序的方法

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace orderByChinese
{
    class Program
    {
        static void Main(string[] args)
        {
            List<Person> Persons = new List<Person> { new Person { name="啊一",age=12}, new Person { name = "播二", age = 12 }, new Person { name = "次一", age = 12 }, new Person { name = "的二", age = 11 } };
            CultureInfo culture = CultureInfo.GetCultureInfo("zh-cn");
            Persons = Persons.OrderByDescending(o => o.age).ThenBy(o => o.name, StringComparer.Create(culture, true)).ToList();
            foreach (var item in Persons)
            {
                Console.WriteLine("姓名:{0},年齡:{1}", item.name, item.age);
            }
            Console.ReadKey();
        }
    }
    public class Person
    {
        public string name { get; set; }
        public int age { get; set; }


    }
}
發佈了101 篇原創文章 · 獲贊 8 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章