Rockbox mail archiveSubject: Re: how is strnatcmp aka "Interpret numbers while sorting" supposed to sort?
Re: how is strnatcmp aka "Interpret numbers while sorting" supposed to sort?
From: Thomas Martitz <thomas.martitz_at_fhtw-berlin.de>
Date: Wed, 18 Mar 2009 23:20:14 +0100
Am 18.03.2009 22:57, schrieb Al Le:
> I think we can't tell for sure what's intentional and what's not. All
> we have is a bunch of files, and it's not our task to infer how it has
> come to it. Guessing what the intention was is an intelligence of a
> higher degree than the natsort!
Right. We cannot surely predict whether it is intentional or accidental.
Which is why we decided to go with the original implementation and say
"the author of the code made it like that".
And, we can only special case very leading zeros. Going back to what was
before yesterday will break zeros within the string again (such as
discnumbers and xxx_00_abc vs xxx_01_abc. See FS#10029.
But that means costumizing the code again (I'm not against it at all).
>>> Either treat digits as number or don't treat them as numbers at all.
> I'm absolutely with you, Dominik. This way the thing the algorithm
> does can be captured in few words, which we accurately did in the
> setting names ("Interpret numbers as ..."). Special treatment of
> leading zeroes, spaces and dots is too much for a usual human being to
There's no special treatment of dots at all. How do you come to that
idea? Zeros are not special treated either. Currently only spaces are a
special case, as they are ignored.
>> Also, which comes first: 001 or 01?
> If strnatcmp tells two strings are equal then strcmp is called which
> always delivers a perfectly predictable result.
Yes, but do we really want them to sort the same? I'm really not sure
about that. Particularly when they have some prefix.
Received on 2009-03-18