Correct sorting of names with numbers

To sort the names of the elements, I want to maintain the numbers correctly. i.e:

1 Hamlet
2 Ophelia
...
10 Laertes

instead

1 Hamlet
10 Laertes
2 Ophelia
...

Does anyone know of a comparison functor that already supports this?
(i.e. a predicate that can be passed to std::sort)

I basically have two templates for support: A leading number (as indicated above) and a number at the end, similar to explorer:

Dolly
Dolly (2)
Dolly (3)

(I think I could do this: compare by character and process numeric values ​​differently. However, this can break unicode collaiton and whatnot)

+3
source share
4 answers

- .
:

+5
+2

Boost Cookbook. Boost Regex, .

http://www.boostcookbook.com/Recipe:/1235053

+1

, , vector > , . . , , .

0

Source: https://habr.com/ru/post/1718172/


All Articles