zsh-users
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Feature request: two level sorting
Date: Sat, 18 Jun 2016 12:56:46 +0200	[thread overview]
Message-ID: <CAKc7PVANAeW=hegg7eoqM2gznvnYaEHXCM2TkKOa1RbS7+5yhg@mail.gmail.com> (raw)
In-Reply-To: <160616002113.ZM23166@torch.brasslantern.com>

On 16 June 2016 at 09:21, Bart Schaefer <schaefer@brasslantern.com> 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


  reply	other threads:[~2016-06-18 10:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-15  5:13 Sebastian Gniazdowski
2016-06-15  5:21 ` Sebastian Gniazdowski
2016-06-15  6:10   ` Sebastian Gniazdowski
2016-06-15 17:12 ` Bart Schaefer
2016-06-15 18:25   ` Mikael Magnusson
2016-06-15 22:38     ` Bart Schaefer
2016-06-15 23:02       ` Mikael Magnusson
2016-06-16 15:43         ` Bart Schaefer
2016-07-01  7:16         ` Sebastian Gniazdowski
2016-07-01 16:43           ` Bart Schaefer
2016-07-02  4:09             ` Sebastian Gniazdowski
2016-07-02 17:18               ` Bart Schaefer
2016-06-16  4:53   ` Sebastian Gniazdowski
2016-06-16  7:21     ` Bart Schaefer
2016-06-18 10:56       ` Sebastian Gniazdowski [this message]
2016-06-19 17:42         ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKc7PVANAeW=hegg7eoqM2gznvnYaEHXCM2TkKOa1RbS7+5yhg@mail.gmail.com' \
    --to=sgniazdowski@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).