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 29905 invoked from network); 7 Jul 2020 16:19:30 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 7 Jul 2020 16:19:30 -0000 Received: (qmail 26972 invoked by alias); 7 Jul 2020 16:19:22 -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: 24986 Received: (qmail 5474 invoked by uid 1010); 7 Jul 2020 16:19:22 -0000 X-Qmail-Scanner-Diagnostics: from out5-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25863. spamassassin: 3.4.4. Clear:RC:0(66.111.4.29):SA:0(-2.6/5.0):. Processed in 0.714772 secs); 07 Jul 2020 16:19:22 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudehgdelfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfgjfhfogggtgfesthejtd dtredtvdenucfhrhhomhepffgrnhhivghlucfuhhgrhhgrfhcuoegurdhssegurghnihgv lhdrshhhrghhrghfrdhnrghmvgeqnecuggftrfgrthhtvghrnhepfeduteegveehvdfhte evtedvudeludeijeeuudeujeejtdetuedtjefhtdfgieetnecukfhppeejledrudejiedr feelrdeileenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhroh hmpegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvg X-ME-Proxy: Date: Tue, 7 Jul 2020 16:18:45 +0000 From: Daniel Shahaf To: zsh-users@zsh.org Subject: Re: How to impose a numeric sort on negative numbers? Message-ID: <20200707161845.6e2b371a@tarpaulin.shahaf.local2> In-Reply-To: <20200707161451.2a62fb22@tarpaulin.shahaf.local2> References: <3580763ca2a81e24786f92071be073833b820b83.camel@ntlworld.com> <20200702113640.3343ff0c@tarpaulin.shahaf.local2> <3f4d22d506fc069965c1e37d0f06ee585a5073dc.camel@ntlworld.com> <20200707161451.2a62fb22@tarpaulin.shahaf.local2> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Daniel Shahaf wrote on Tue, 07 Jul 2020 16:14 +0000: > Daniel Shahaf wrote on Fri, 03 Jul 2020 22:23 +0000: > > > 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). > > > > FWIW, I thought at first reading that that second sentence referred to > > the `tt(-)' in the parameter expansion flags, not to the one in the > > input data. I'd never have expected "-" or "-foo" to be considered an > > integer in the first place, just like "" and "foo" aren't considered integers. > > > > Incidentally, should "+42" be sorted as an integer? Right now it isn't. > > The following patch addresses the first issue and documents "+42" as a > possible future extension. > > diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo > index 41ad967b2..21ecf9d6e 100644 > --- a/Doc/Zsh/expn.yo > +++ b/Doc/Zsh/expn.yo > @@ -1092,15 +1092,18 @@ Convert all letters in the result to lower case. Equivalent wdiff for review: diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index 41ad967b2..21ecf9d6e 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -1092,15 +1092,18 @@ Convert all letters in the result to lower case. item(tt(n))( Sort decimal integers numerically; if the first differing characters of two test strings are not digits, sorting is lexical. {+`tt(+)' and `tt(-)' are not treated specially; they are treated as+} {+any other non-digit.+} Integers with more initial zeroes are sorted before those with fewer or none. Hence the array [-`tt(foo1-]{+`tt(foo+24 foo1+} foo02 foo2 foo3 foo20 foo23)' is sorted into the order shown. May be combined with `tt(i)' or `tt(O)'. ) item(tt(-))( As tt(n), but a leading minus sign indicates a negative decimal integer. A [-`tt(-)'-]{+leading minus sign+} not followed by an integer does not trigger numeric sorting. {+Note that `tt(+)' signs are not handled specially (this may change in the+} {+future).+} ) item(tt(o))( Sort the resulting words in ascending order; if this appears on its