From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 750 invoked by alias); 18 Jun 2016 10:57:11 -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: 21679 Received: (qmail 26533 invoked from network); 18 Jun 2016 10:57:09 -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,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=TuNqRjpGeFpF8JgchndUxy3TaOgvJ7506Zv4CCeDJEY=; b=PHW0UZQoeZwHN6PbuaIIcnIptpeUHNAYlFFymOky6dyLpEtVUPQLKtjSD2uWuf9uqd AvBZifTh/A4KvCoCdWvAfHCIW5K0WpmO291iy/CQaowBjvnmx9H6ZVyeCp9yZtKxO5NN kP1k6R/cIKEX9WJ/oMfmQLeORNPn13rzKAS6DPuqOye4J6xZzIE9mWAmluCN8pUTXC41 tH3q5/w+h3N3yQOL0f/Ak8oAk6nKiCnzDE4C8YrLVfLeysdvx2r2s5vhznkjBuvS6yaF SphcCiw2K/AdEwU3aLZVIOrGzIcnspz/BxjFLwCcWaIw4WkMlGPV+hk9dAnwZ1EjbZe0 yYeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=TuNqRjpGeFpF8JgchndUxy3TaOgvJ7506Zv4CCeDJEY=; b=hesfx3Ww8QIvIz/8H6mj7jvelE+fgZrWc5gDXQv4m+B98lXPUWNlcZo7PE7c/PegY1 1vSl1jKQMwGeGuNCPD7J22UuRoMw+8bUwerd9R9F2wc+aF/DhSKWQNycbd+2+HamSW17 ubPmdwCSKI+6BJSF/8OmlcqgPKS52TAPg4b7One9QVRO8itnOWvd5hcv262ftuP50upr AJmSCDAaKhevcw+FXE1zWcCFCqL+HyQiZoEGcSADuTK3+sfOIVztuk6rXMPqKPI77opb 9o0f251xIcqTiW4CoF/ULWA+UqKH/ZcHTezgbD1nlHEuYD23LuIiMH0g4iCGqHtGxQD6 k16A== X-Gm-Message-State: ALyK8tI91dYw1E1SsnfLutQvYQojyilYR7cXGRtKd2uJUFvLXr1QJkJc0oMuqpSJx0Rx2rdXIs9+Uvz4GF0A3Q== X-Received: by 10.55.104.213 with SMTP id d204mr8342381qkc.208.1466247425860; Sat, 18 Jun 2016 03:57:05 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <160616002113.ZM23166@torch.brasslantern.com> References: <160615101239.ZM21280@torch.brasslantern.com> <160616002113.ZM23166@torch.brasslantern.com> From: Sebastian Gniazdowski Date: Sat, 18 Jun 2016 12:56:46 +0200 Message-ID: Subject: Re: Feature request: two level sorting To: Bart Schaefer Cc: Zsh Users Content-Type: text/plain; charset=UTF-8 On 16 June 2016 at 09:21, Bart Schaefer wrote: > So what you're really suggesting is -- > > 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 > > -- and you want a syntax that passes the name of AB, the order to be > applied to AB, and the secondary order of AA, via the expansion flags > of a reference to AA. > > Have I got it this time? I think yes. Not sure how tricky GROUP BY sorting is, but it sounds tricky. > What if you need "two levels" of sorting for the desired order AB? Yeah that's an issue. But that's least we can do, GROUP BY sorting on one group. What's important in this, is that it will allow to avoid O(N^2) situations. Ultimate solution would be own comparing code, thing used e.g. C++ where it has proven to be well abstract, allowing to face variety of demands, rather all of them. What I'm really hoping is that the (x:groups:) flag would be similarly elastic, resulting in uses that are hard to predict. But I cannot provide any trick that (x:groups:) would allow. Also, own comparing code would be rather slow? Zsh doesn't do compilation I think, so it would evaluate the code at each comparison, so that's a drawback. (x:groups:) wouldn't have this issue. And it could open door to variety of O(N^2)-avoid tricks. PS. Could the (x:groups:) array contain multiple groups separated via available-separator e.g. ":"? I mean, one can have objections to mess with his original data adding prefix separated with ":". That's why I've chosen the imperative way of solving, the loop mentioned. Didn't want to mess with data, change way it looks and track this with extensive thought. But I could surely mess with separate groups array, it would feel natural to provide "A:1:x" there and similar sub-group-pretending things. Best regards, Sebastian Gniazdowski