Boost logo

Boost :

From: Andy Tompkins (atompkins_at_[hidden])
Date: 2005-12-22 11:01:42

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,

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
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

Boost list run by bdawes at, gregod at, cpdaniel at, john at