Zsh Mailing List Archive
Messages sorted by:
Re: Feature request: two level sorting
- X-seq: zsh-users 21679
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Feature request: two level sorting
- Date: Sat, 18 Jun 2016 12:56:46 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- 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==
- In-reply-to: <160616002113.ZM23166@torch.brasslantern.com>
- List-help: <mailto:email@example.com>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVAsLwNVP0vjTvBebP5u+Ahe03yXaWxkvytOx4EPkN4V9Q@mail.gmail.com> <160615101239.ZM21280@torch.brasslantern.com> <CAKc7PVBztgxUOdeA-L=wfvwKd34JTz0eV2GD5tE17hVMNr72Dw@mail.gmail.com> <160616002113.ZM23166@torch.brasslantern.com>
On 16 June 2016 at 09:21, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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
Messages sorted by: