How to get Swedish sort order for strings

蓝咒 提交于 2021-01-27 04:59:07

问题


I am having a problem sorting Swedish strings.

I am having problems with the following characters: v, w, å, ä, ö.

new[] { "ö", "ä", "å", "wa", "va", "wb", "vb", "a"  }
.OrderBy(x => x, new CultureInfo("sv-SE").CompareInfo.GetStringComparer(CompareOptions.None))

Expected: a, va, vb, wa, wb, å, ä, ö

Actual: a, va, wa, vb, wb, å, ä, ö

Is the there any option to make it sort the strings as expected?


回答1:


As a work-around I have switched to the culture se-SE (Sami) just for sorting alphabetic strings correctly while I wait for the .NET sorting rules to be updated.

Update:

Here is the github issue: https://github.com/dotnet/corefx/issues/37753

Update2:

The issue is not with .NET, it is the sorting rules defined in the underlying operating system. This error is only present on Windows.



来源:https://stackoverflow.com/questions/56188303/how-to-get-swedish-sort-order-for-strings

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!