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?
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 wellknown 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.
Linus
Received on 20090319
Page was last modified "Jan 10 2012" The Rockbox Crew
