At the risk of revealing what some of the ancient innards of acedb
code look like, here is the C code for lexstrcmp() which provides the
acedb sort ordering. This is case insensitive - there is also
equivalent case sensitive code for when that is needed.
Richard
PS I also find this newsgroup useful despite the SPAM.
/* Correctly sorts anything containing integers */
int lexstrcmp(char *a,char *b)
{ register char c,d,*p,*q ;
register int nbza, nbzb ; /* nb de zeros en tete */
register int nbzReturn = 0 ;
while (*a)
{ /* Bond007 < Bond07 < Bond7 < Bond68 */
if (isdigit((int)*a) && isdigit((int)*b))
{ for (nbza = 0 ; *a == '0' ; ++a, nbza++) ; /* saut des premiers zeros
*/
for (nbzb = 0 ; *b == '0' ; ++b, nbzb++) ;
for (p = a ; isdigit((int)*p) ; ++p) ;
for (q = b ; isdigit((int)*q) ; ++q) ;
if (p-a > q-b) return 1 ; /* the longer number is the bigger */
if (p-a < q-b) return -1 ;
while (isdigit ((int)*a))
{ if (*a > *b) return 1 ;
if (*a++ < *b++) return -1 ;
}
if (!nbzReturn)
{ if (nbza < nbzb) nbzReturn = +1 ;
if (nbza > nbzb) nbzReturn = -1 ;
}
}
else
{ if ((c=freeupper(*a++)) > (d=freeupper(*b++))) return 1 ;
if (c < d) return -1 ;
}
}
if (!*b)
return nbzReturn ;
return -1 ;
}
---