How to implement a natural sort algorithm in c++?

后端 未结 8 1541
不思量自难忘°
不思量自难忘° 2020-11-30 10:21

I\'m sorting strings that are comprised of text and numbers. I want the sort to sort the number parts as numbers, not alphanumeric.

For example I want: abc1def, ...

8条回答
  •  醉话见心
    2020-11-30 10:49

    This is known as natural sorting. There's an algorithm here that looks promising.

    Be careful of problems with non-ASCII characters (see Jeff's blog entry on the subject).

提交回复
热议问题