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:43:28 +0100
Al Le schrieb:
> On 18.03.2009 23:20, Thomas Martitz wrote:
>> Right. We cannot surely predict whether it is intentional or accidental.
> Here I'm with you
>> Which is why we decided to go with the original implementation and say
>> "the author of the code made it like that".
> But here not anymore. I think the verbal description should be first,
> and then the implementation of it. You say "we take an implementation
> (as the author did it) and try to describe it". I say "we define a
> simple rule (but which sorts the names as users expect it) and
> implement it. If the original algorithm would have to be modified then
> we modify it".
Yes, I can live with that.
> To that simple rule (treating a sequence of numbers as a number) I'd
> probably add the rule that many subsequent spaces are folded to one.
> E.g. "A space space B" would be equal to "A space B" modulo natsort.
> strcmp would be used to resolve the case.
>> And, we can only special case very leading zeros.
> They wouldn't have to be treated specially, since the rule is general
> enough to handle them.
Only if you want to break decimal numbers or discnumber.tracknumber (or
any other numbers which have a constant prefix in the strings to be
This is what we had, and it turned out to be flawed. We cannot ignore
leading zeros of numbers within the string, only at the very beginning.
Received on 2009-03-18