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: Paul Louden <paulthenerd_at_gmail.com>
Date: Wed, 18 Mar 2009 17:01:07 -0500
Dominik Riebeling wrote:
> On Wed, Mar 18, 2009 at 10:22 PM, Paul Louden <paulthenerd_at_gmail.com> wrote:
>> I agree that it could be unintentional, but disagree that "numeric sorting"
>> matters in this case - if you have a mix of random songs, why does 03 need
>> to be between 2 and 4? Meanwhile, if someone intentionally prefixes
>> something with a 0, they intend for it to be first, so it should be. This
>> sounds like a case of "let's make the unimportant case work one way, while
>> choosing to break the case where people make intentional changes."
> You have a point, but if we assume people to add leading zeros
> *intentionally* can't we assume those people to number their files
> correctly in the first place, thus not having any need for this
> "natural" sorting anyway? I'm pretty confident that there are users
> careless enough to name files "3", "05", "7" and expecting them to get
> sorted as "3", "05", "7". If we consider leading zeros as intentional
> do we need this strnatcmp at all? If we not skip leading zeros are we
> treating digits as numbers at all? I wouldn't say so.
> Besides, couldn't that also create a sorting like "10", "13", "02",
> "04" as 0 is a character here and thus sorted separately? Such a
> sorting would be wrong if one names his files always using leading
> zeros, especially if numbers are always sorted first.
You really believe a person, while naming files, would number them "3,
05, 7"? Why would they add the 0 onto the 5 one if they're already
typing single-digit numbers?
Can you give me a realistic case where someone wants their files in the
order "3, 05, 7" and has named them themselves?
We were fixing, previously, the case where people had chosen names of 1,
2, 3, 4, 5, 6, 7, 8, 9, 10 and not known they *must* use leading zeros
to prevent bad sorting. But I don't think it's a fair assumption to go
as far as saying "when they add a character, they didn't mean to type it."
> Does "alter the sorting" require you to use digits? At least I usually
> prepend character if I want something to get sorted at the top or
> bottom or indexes like "a", "b" after the leading number.
"A" doesn't come before "1" so a1 to come before 1 doesn't work. 01
could, except we would be preventing it. I don't see why we should force
people not to use zeros.
> Good point. Though if we only address the naming issue we kinda create
> our own sorting, don't we?
I don't know what you mean by "only address the naming issue."
Received on 2009-03-18