zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: Peter Stephenson <p.w.stephenson@ntlworld.com>,
	Zsh Users <zsh-users@zsh.org>
Subject: Re: How to impose a numeric sort on negative numbers?
Date: Thu, 2 Jul 2020 08:46:08 -0700	[thread overview]
Message-ID: <CAH+w=7Y31mfOrFyYUnAZwR5Bx1vOmTUJFVmKi6qhr1uEP1u=4w@mail.gmail.com> (raw)
In-Reply-To: <20200702113640.3343ff0c@tarpaulin.shahaf.local2>

(Dangit, I'm not getting Peter's mail again)

On Thu, Jul 2, 2020 at 4:38 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
>
> Peter Stephenson wrote on Wed, 01 Jul 2020 20:42 +0100:
> > +++ b/Doc/Zsh/expn.yo
> > @@ -1097,6 +1097,11 @@ are sorted before those with fewer or none.  Hence the array `tt(foo1 foo02
> >  foo2 foo3 foo20 foo23)' is sorted into the order shown.
> >  May be combined with `tt(i)' or `tt(O)'.
> >  )
> > +item(tt(DASH()))(
> > +As tt(n), but a leading minus sign indicates a negative decimal
> > +integer.  A solo `tt(DASH())' not followed by an integer does
> > +not trigger numeric sorting.
> > +)

It might be possible to change this.  For numeric sort, the function
eltpcmp() in sort.c ignores everything other than digits that compares
the same in any pair of the strings.  It could recognize a leading
hyphen as special.

The questionable thing is what to do about embedded hyphens.  If I'm
asked to sort (1-5 1-3, 1-4 1-2) numerically, what does the hyphen
mean?  Right now it's just ignored.  Reverse the order of the sort
every time we encounter a hyphen?

  parent reply	other threads:[~2020-07-02 15:47 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-01 17:45 Sebastian Gniazdowski
2020-07-01 18:02 ` Mikael Magnusson
2020-07-01 18:07   ` Sebastian Gniazdowski
2020-07-01 18:12     ` Roman Perepelitsa
2020-07-03 18:12     ` Lewis Butler
2020-07-03 18:35       ` Bart Schaefer
2020-07-01 19:42   ` Peter Stephenson
2020-07-02 11:36     ` Daniel Shahaf
2020-07-02 12:00       ` Peter Stephenson
2020-07-03 16:21         ` Hyphens, minuses, and dashes (was: Re: How to impose a numeric sort on negative numbers?) Daniel Shahaf
2020-07-02 15:46       ` Bart Schaefer [this message]
2020-07-03 20:08         ` How to impose a numeric sort on negative numbers? Peter Stephenson
2020-07-03 20:15           ` Bart Schaefer
2020-07-03 22:23           ` Daniel Shahaf
2020-07-07 16:14             ` Daniel Shahaf
2020-07-07 16:18               ` Daniel Shahaf
2020-07-01 18:48 ` Lawrence Velázquez
2020-07-06  7:15   ` Sebastian Gniazdowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7Y31mfOrFyYUnAZwR5Bx1vOmTUJFVmKi6qhr1uEP1u=4w@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=d.s@daniel.shahaf.name \
    --cc=p.w.stephenson@ntlworld.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).