Why does “-less” sort after “hello” instead of before it?

后端 未结 4 1270
心在旅途
心在旅途 2021-01-05 17:19

I\'m seeing some very strange sorting behaviour using CaseInsensitiveComparer.DefaultInvariant. Words that start with a leading hyphen \"-\" end up sorted as if the hyphen w

4条回答
  •  無奈伤痛
    2021-01-05 17:30

    My guess would be that a dash immedately before a letter is being ignored, for purposes of sorting. When you sort a list of words, you'd like "inter-nation" and "international" to be next to each other, wouldn't you? A dash by itself, on the other hand, is considered significant.

提交回复
热议问题