From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15789 invoked from network); 3 Jul 2020 20:09:33 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 3 Jul 2020 20:09:33 -0000 Received: (qmail 10469 invoked by alias); 3 Jul 2020 20:09:20 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: Sender: zsh-users@zsh.org X-Seq: 24978 Received: (qmail 3820 invoked by uid 1010); 3 Jul 2020 20:09:20 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-1.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25857. spamassassin: 3.4.4. Clear:RC:0(80.0.253.65):SA:0(-2.0/5.0):. Processed in 2.922433 secs); 03 Jul 2020 20:09:20 -0000 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _smtprelay.virginmedia.com designates 80.0.253.65 as permitted sender) X-Originating-IP: [86.16.88.158] X-Authenticated-User: p.w.stephenson@ntlworld.com X-Spam: 0 X-Authority: v=2.3 cv=C6nHNzH+ c=1 sm=1 tr=0 a=MiHCjVqLJ44lE3bxSlffFQ==:117 a=MiHCjVqLJ44lE3bxSlffFQ==:17 a=IkcTkHD0fZMA:10 a=5jbm4OMHsSNhNnma66kA:9 a=QEXdDO2ut3YA:10 Message-ID: <3f4d22d506fc069965c1e37d0f06ee585a5073dc.camel@ntlworld.com> Subject: Re: How to impose a numeric sort on negative numbers? From: Peter Stephenson To: zsh-users@zsh.org Date: Fri, 03 Jul 2020 21:08:38 +0100 In-Reply-To: References: <3580763ca2a81e24786f92071be073833b820b83.camel@ntlworld.com> <20200702113640.3343ff0c@tarpaulin.shahaf.local2> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfLpEYhjoizt+1DUwLZ4Mx7xcb7mzm2RuJdywc84bE90Agvvg0bpdbE+Zy3cI1EeQwYBhqEmbtu4enJOhCEM9dc6GLFwaRN8N68XK+CUdogS+0kE/tYpD eyIGwjWHjea2R70j9gezJrFHbdj/0dxbYie/jw/aOuw2BI3WI0UmOwfQ On Thu, 2020-07-02 at 08:46 -0700, Bart Schaefer 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. (I've committed it with DASH() turned into -.) The doc was just to record the fact that I didn't treat a "-" as "-0", just as a character "-". That was a deliberate choice --- I'm assuming the usual case of a numeric sort will have at least one decimal digit in the part to be sorted and anything else is just a hyphen (and definitely not a dash). pws