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 25275 invoked from network); 2 Jul 2020 15:47:09 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 2 Jul 2020 15:47:09 -0000 Received: (qmail 16204 invoked by alias); 2 Jul 2020 15:46:55 -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: 24974 Received: (qmail 7870 invoked by uid 1010); 2 Jul 2020 15:46:55 -0000 X-Qmail-Scanner-Diagnostics: from mail-oi1-f177.google.com 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(209.85.167.177):SA:0(-1.9/5.0):. Processed in 1.773743 secs); 02 Jul 2020 15:46:55 -0000 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.167.177 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=y4f+DDLtY00sTX4IV2BibY25cD3oIOo5EPhSCdzG6Zs=; b=O0uvmO7kXBxos3HY4CzUXveyL7fbVJS4QzgILMS4pODy/bs3lvVgfQEqWBXeA9Hnlx lko3TiCdzKTlymyARHIxx+K/7gu9sENHimc3JQV/9/DTrtLpSL/+IGInltT5kyRUqrqm oP8vztD+zE4bsEXhgsHdntV4wkm+20ejwf6zGojENQY7SaRJcPqHSh+t4dVGWDSnQV78 TiiOWhaLQVMhL4z+ZXcgbRCL+2DkbMuVITl0YEwGAodP2nw+8FGTPQJitLwzoUXAt4Cp JMfsQ0rYsK/j2HBtfy9MJzg/PWkH8eJQYHv7bO+nljFEYOUKoRq0SHe4a3qg1hgX3z20 lwrQ== X-Gm-Message-State: AOAM532f3MeJwJtwSZos35Pxjw4/0dPANXzVcQt00EvlvP6wch2zRD+3 JXElWFyiZdPAPyQmFCjOl93dRfF0bfI+Qh17Zah0tQ== X-Google-Smtp-Source: ABdhPJyFO7c4C39UsaGCAqgpYTKoGVgohg2kGl9PrUxDwDq0cU/jvwMrvxIsMPChucURC+Asr8R1gTKpUNGUaZRBPIc= X-Received: by 2002:aca:4186:: with SMTP id o128mr15789114oia.173.1593704779406; Thu, 02 Jul 2020 08:46:19 -0700 (PDT) MIME-Version: 1.0 References: <3580763ca2a81e24786f92071be073833b820b83.camel@ntlworld.com> <20200702113640.3343ff0c@tarpaulin.shahaf.local2> In-Reply-To: <20200702113640.3343ff0c@tarpaulin.shahaf.local2> From: Bart Schaefer Date: Thu, 2 Jul 2020 08:46:08 -0700 Message-ID: Subject: Re: How to impose a numeric sort on negative numbers? To: Daniel Shahaf Cc: Peter Stephenson , Zsh Users Content-Type: text/plain; charset="UTF-8" (Dangit, I'm not getting Peter's mail again) On Thu, Jul 2, 2020 at 4:38 AM Daniel Shahaf 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?