Interest in a function object to sort strings more naturally?

22 Dec
2005
22 Dec
'05
4:01 p.m.
I have written a function object to sort string alpha-numerically. If a string contains a number, that part is converted to an int and compared as ints. Thus "2" comes before "10". For example the list {a1, a10, a11, a2} would be sorted as {a1, a2, a10, a11} Example use code: { vector<string> my_list; //populate list sort(my_list.begin(), my_list.end(), lt_alphanum<char>()); } The class lt_alphanum splits the strings into sections containing digits, and non-digits. It then compares successive sections such that if two sections both contain digits, they are converted to ints and compared. Otherwise the sections are compared normally. I hope I am being clear. Andy Tompkins
7179
Age (days ago)
7179
Last active (days ago)
0 comments
1 participants
participants (1)
-
Andy Tompkins