[Jprogramming] Sorting on two keys

R.E. Boss r.e.boss at outlook.com
Wed Jan 23 14:31:18 UTC 2019


Thanks Brian, I'm pleased to hear you enjoyed it.

Well, one can argue whether an explicit verb is a one-liner or not. 
At least it was too much work for me to fiddle out how to write this tacitly. We have high priests for that, haven't we?

BTW, it is more than a couple of years ago C. did not have an obverse.


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: Programming <programming-bounces at forums.jsoftware.com>
> Namens Brian Schott
> Verzonden: woensdag 23 januari 2019 14:47
> Aan: Programming forum <programming at jsoftware.com>
> Onderwerp: Re: [Jprogramming] Sorting on two keys
> 
> RE,
> 
> Previously I learned via your code a use of C. that was eye-opening.
> This time, I learned via your code how a multi-x can be used in a one liner.
> 
> Very good.
> 
> On Wed, Jan 23, 2019 at 5:45 AM R.E. Boss <r.e.boss at outlook.com> wrote:
> 
> > If your x variable denotes the columns to be sorted plus the way in
> > which that should be done, like
> > 0 3 2 1,:_1 1 _1 1
> > Then the (explicit) toolbox verb could be
> >
> > foo=:4 : ('''x1 x2''=.x' ; 'x2([/: *"1)&.:(x1&C."1)~ y')
> >
> >    a ,.@;~&|:   (0 3 2 1,:_1 1 _1 1) foo a=.3#.^:_1 i.30
> > +-----------------------------------------------------------+
> > |1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0|
> > |0 0 0 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2|
> > |0 0 0 2 2 2 1 1 1 0 0 0 2 2 2 1 1 1 0 0 0 2 2 2 1 1 1 0 0 0|
> > |0 1 2 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2|
> > +-----------------------------------------------------------+
> > |0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1|
> > |0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 0 0 0|
> > |0 0 0 1 1 1 2 2 2 0 0 0 1 1 1 2 2 2 0 0 0 1 1 1 2 2 2 0 0 0|
> > |0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2|
> > +-----------------------------------------------------------+
> >
> >
> > R.E. Boss
> >
> >
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm


More information about the Programming mailing list