I would like to sort alphanumeric strings the way a human being would sort them. I.e., \"A2\" comes before \"A10\", and \"a\" certainly comes before \"Z\"! Is there any way to d
It really depends what you mean by "parser." If you want to avoid writing a parser, I would think you should avail yourself of library functions.
isalnum
and backtrack-checking for +
or -
if it is a number. Use strtold
in-place to find the end of a numeric subsequence.strcoll
to compare alphabetic subsequences within the current locale.strtold
to compare numeric subsequences within the current locale.strcmp
.This algorithm has something of a weakness in comparing numeric strings which exceed the precision of long double
.