Sorting names with numbers correctly
c++, predicate, sorting, string-comparison
Solution
That's called alphanumeric sorting. Check out this link: The Alphanum Algorithm
Problem
For sorting item names, I want to support numbers correctly. i.e. this: ``` 1 Hamlet 2 Ophelia ... 10 Laertes ``` instead 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)