From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7467 invoked by alias); 19 Jun 2016 17:41:56 -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: X-Seq: 21681 Received: (qmail 8719 invoked from network); 19 Jun 2016 17:41:54 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=sNyMFYfM10yTAHMorDSIEemoqRhP7f3RXotC92txYWM=; b=A+O15rQK+10+igwak3kbBKT1nVBgciqYqfgTZgdOrVhMfjjpsZ3kIf04wB/tFOgHXv UAH0FhLcqjwGzqmnI3sPn1OadujJoxqRagiRjQSTzLk/sG6gh83mfP1scxCDDUm5enkJ fHXell/R9WKiXJ7isVQEIhIpidf081qHLVe6Hgr8l/31HDI2vfLH8yqho7YjVvRQWKkQ uZxB8bStXAu3qzd61zswpq6wpW3EuXDRxhSH37IAEH+xsnGrsicfkkRai2PcjaL6C8ia MsAaoehE7MWcXNcUxeB2veqCyDuIzU2IlErhMt8PFyE07ugBylHRE6UW8xthepvZW7Q/ NuNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=sNyMFYfM10yTAHMorDSIEemoqRhP7f3RXotC92txYWM=; b=iupN4o86mLYZdjrIrZGnh/wCJ97PGysrSUtoMjxVLl3nbTjWPvGh1u7qzDMHSJ3B1j 5XuMSE+18PnRi8RCh5cDkD0bIS4dszu+xP8IN16m8+cOoKhsg858ZMMG7I+ESQ3drT9J utDnRDVij3QeMWACWBzCixSQoliy/Oa4zkB69lMfZSCq6ZdMNd1tmUZV15XNXREo7Wyx ZpsSk999R+aZfo2O2mURkj2Kg0vn5aA4xwi0fmJQ8FFyRFhNKD8G4dFIUEJ8HRtxiWt+ LmMaGN7a8En+ZQZfcra2VvYIoOUblk459Qpd3UWgiWTllRwsEi2NBEZEgc7x5wQ+VWRP qvBg== X-Gm-Message-State: ALyK8tJB3qca264OaainpjbmHF6O9BadkE1aiYjAUJQMqLilW5bMFlsZINYh78WVy1JllA== X-Received: by 10.66.170.168 with SMTP id an8mr16530521pac.47.1466358110935; Sun, 19 Jun 2016 10:41:50 -0700 (PDT) From: Bart Schaefer Message-Id: <160619104220.ZM1378@torch.brasslantern.com> Date: Sun, 19 Jun 2016 10:42:20 -0700 In-Reply-To: Comments: In reply to Sebastian Gniazdowski "Re: Feature request: two level sorting" (Jun 18, 12:56pm) References: <160615101239.ZM21280@torch.brasslantern.com> <160616002113.ZM23166@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh Users Subject: Re: Feature request: two level sorting MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jun 18, 12:56pm, Sebastian Gniazdowski wrote: } Subject: Re: Feature request: two level sorting } } On 16 June 2016 at 09:21, Bart Schaefer wrote: } > Given two arrays AA and AB which must be of equal length: } > (1) sort AB and apply that new ordering to the elements of AA } > (2) except that if two elements of AB are the same, use another } > sort to order the corresponding elements of AA } } I think yes. Not sure how tricky GROUP BY sorting is, but it sounds } tricky. Well, firstly GROUP BY doesn't work the way you seem to think. It's not a sort; in SQL a GROUP BY will produce a single row of output that combines the data from the matching rows, not the original rows arranged in groups. The order in which the matching rows accumulate is unspecified; any ORDER BY is applied to the resulting composites. What you're really asking for in your original example is sorting by two different keys, except that you want one key to be a substring of the input data. This thing with the parallel arrays amounts to nothing more than a way to separate out the substring so you can pretend there are two distinct fields each of which is a key. The icky bit with zsh is that to sort with any efficiency on multiple fields you need to be able to manipulate arrays of pointers, but parameter expansion only gives you arrays of values. So while I appreciate your "didn't want to mess with data" sentiment, it might require a lot of reworking of the parameter implementation to manipulate anything other than the data. In other words, even if I am correct about "given two arrays ..." you shouldn't hold your breath expecting that to get implemented. } Ultimate solution would be own comparing code See my other response to Mikael. tl;dr: Not safe, not something shells were intended to do, and already done better in other languages.