Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide
translations



Rockbox mail archive

Subject: 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: Dominik Riebeling <dominik.riebeling_at_gmail.com>
Date: Wed, 18 Mar 2009 23:21:35 +0100

On Wed, Mar 18, 2009 at 11:01 PM, Paul Louden <paulthenerd_at_gmail.com> wrote:
> 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?

Just consider this scenario: someone is creating a mix folder by
copying various files to it. He wants a given order. Now some files
are named with 0 prefixes, others not. He decides to not use 0
prefixes, possibly because of laziness, but leaves them on the files
he doesn't need to change at all -- if "05" is to become track 5 he
doesn't need to change anything. As for track "09" which should become
3 he'd use "3". Too far-fetched?

> 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."

well, treating a number as such includes stripping leading zeros from
it, at least from my understanding. It won't do any harm on properly
named files, and I don't see a reason why a user would want to prefix
with 0 just to change sorting. We're restricting digit-postfixes to
numbers this way (which most people will consider less problematic but
we still restrict the users: "01", "02", "020", "03" won't work
anymore while it does when sorting ASCII. The user will still think of
2-digit numbers).

In any case, it would be interesting to see how windows does the
sorting, as the most users will be used to that way of doing it.

> "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.

Sorry, got my thoughts mixed up. I use letter postfixes to get it
sorted after that specific number, i.e. 01, 03a, 03b, 04 but prefixed
to get it sorted at the top or bottom of the list (a1 would come after
numbers, _1 usually before it -- unless the sorting treats _ as space
and ignores spaces).


 - Dominik
Received on 2009-03-18

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy