Sorting strings containing numbers in a user friendly way

前端 未结 3 479
滥情空心
滥情空心 2020-12-10 01:34

Being used to the standard way of sorting strings, I was surprised when I noticed that Windows sorts files by their names in a kind of advanced way. Let me give you an examp

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-10 02:13

    Jeff wrote up an article about this on Coding Horror. This is called natural sorting, where you effectively treat a group of digits as a single "character". There are implementations out there in every language under the sun, but strangely it's not usually built-in to most languages' standard libraries.

提交回复
热议问题