对于排序项目名称,我想正确支持数字。即:
1 Hamlet 2 Ophelia ... 10 Laertes而不是
1 Hamlet 10 Laertes 2 Ophelia ...有没有人知道已经支持该函数的比较函子? (即一个可以传递给 std :: sort )
我基本上有两种模式支持:前导数字(如上)和末尾数字,类似于explorer:
多莉多莉(2)多莉(3) pre>(我想我可以工作:比较字符,并且处理数字值不同的,但是,这可能会破坏unicode collaiton和whatnot)
解决方案这称为字母数字排序。 签出此链接:字母算法
For sorting item names, I want to support numbers correctly. i.e. this:
1 Hamlet 2 Ophelia ... 10 Laertesinstead of
1 Hamlet 10 Laertes 2 Ophelia ...Does anyone know of a comparison functor that already supports that? (i.e. a predicate that can be passed to std::sort)
I basically have two patterns to support: Leading number (as above), and number at end, similar to explorer:
Dolly Dolly (2) Dolly (3)(I guess I could work that out: compare by character, and treat numeric values differently. However, that would probably break unicode collaiton and whatnot)
解决方案That's called alphanumeric sorting. Check out this link: The Alphanum Algorithm
更多推荐
使用数字正确排序名称
发布评论