OrderBy with Swedish letters

后端 未结 4 892
旧巷少年郎
旧巷少年郎 2021-01-04 08:19

I have a list of my custom class Customer and I want to sort them alphabetically by Title. So I wrote

myList = myList.OrderByDescending(x => x.Title).ToL         


        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-04 08:55

    You can use culture specific StringComparer, see here.

    CultureInfo culture = new CultureInfo("sv-SE");
    var result = myList.OrderByDescending(x => 
                   x.Title, StringComparer.Create(culture, false));
    

提交回复
热议问题