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



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: Linus Nielsen Feltzing <linus_at_haxx.se>
Date: Thu, 19 Mar 2009 07:42:59 +0100

Dominik Riebeling wrote:
> Now, how should this feature sort? From my point of view, I'd expect it to
> - treat digits as numbers. A value of "00" equals to zero and thus
> gets sorted before the number 1, regardless if that is "1", "01" or
> "001". Completely skipping the zero (as it's only leading zeros) is as
> broken as to not strip leading zeros -- "003" should equal to 3 and
> "01" to 1, thus the latter sorting before the former.

I totally agree. Leading zeros should be ignored when comparing numbers.
It is in my opinion the least surprising way of doing it.

Linus
Received on 2009-03-19


Page was last modified "Jan 10 2012" The Rockbox Crew
aaa