dev builds
themes manual
device status forums
mailing lists
IRC bugs
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 <>
Date: Thu, 19 Mar 2009 08:19:16 +0100

Paul Louden wrote:
> No, this isn't. This is "having intuitive handling of numbers as
> normally written by people." People don't normally precede numbers with
> a 0 unless there's a specific reason to.

I'd think that many files will have names with leading zeros, especially
if they are copied from a player that doesn't support natural sorting,
where the user will have added leading zeros to force a correct sorting.

Also, you seem to forget the very reason that we implement natural
sorting in the first place, which is to sort numbers in a natural way,
so the user finds numbered files where he expect them to be, without
having to change the file names.

Further, natural sorting strives to sort numbers in a way that humans
*expect* them to be sorted. Leading zeros are insignificant when
treating numbers, that is a mathematical rule that the vast majority of
people knows. I dare to say that people in general expect the browser to
ignore leading zeros.

If it sorts 007 after 6, I fail to see how it would be surprising to the
user in any way. It is after all a well-known mathematical rule, and a
rule that the major file browsers follow. If we claim to sort numbers,
we should do so, and not change the fundamental rules of mathematics.

Received on 2009-03-19

Page template was last modified "Sat Sep 18 20:21:06 2021" The Rockbox Crew -- Privacy Policy