Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Surprising behaviour with numeric glob sort
On 2017-06-03 22:16:46 +0100, Stephane Chazelas wrote:
> 2017-06-02 16:19:05 -0700, Bart Schaefer:
> > Well, one could argue that "-10" should be treated as negative ten
> > and therefore should sort before negative three, but I'm not sure
> > we want to get into that.
>
> The (my at least) main usage for *(n) is to sort version numbers
> like zsh-3.0, zsh-3.1, zsh-4. So handling negative numbers
> wouldn't help in those cases.
I often uses "-" as a separator, so that I expect "foo-1" to come
before "foo-2".
And note that in Unicode, the real minus sign is U+2212.
> When comparing "zsh-3" with "zsh2", we compare the non-numeric
> prefix: "zsh-" and "zsh". And already, at that point, "zsh" is
> less than "zsh-", so we stop here (zsh2 < zsh-3)
I don't think this is the correct method. In some locales, digits
come after "-". So, IMHO, "zsh-0" should be compared with "zsh0".
I expect numeric sort and the normal sort be equivalent when all
numbers have a single digit. Numeric sort is just a generalization
to an infinite digit set (a number being regarded as an element
of this digit set).
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author