SQLite Forum

Natural sort order
Login
FWIW, my impl uses the trick below, to avoid any `isdigit()` in many cases. --DD

```
const int diff = l_char - r_char;
if (-9 > diff || diff > 9) {
  // *both* chars cannot be digits, so normal lexicographical compare,
  // even for the mixed char-digit or digit-char cases.
  return diff;
}
```

Our impls are essentially the same (including skipping leading zeros),  
I just didn't think of using `memcmp()` myself, I reloop on the chars.