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


> -----Oorspronkelijk bericht-----
> Van: Programming <[email protected]>
> Namens Jimmy Gauvin
> Verzonden: dinsdag 22 januari 2019 00:34
> Aan: [email protected]
> Onderwerp: Re: [Jprogramming] Sorting on two keys
> 
> HI,
> 
> thanks for all the answers, and the insights into J and sorting.
> The version applicable to my sorting needs is indeed the classic primary key,
> secondary key sort.
> And the R.E. Boss version is going into my toolbox.
> 
> 
> Jimmy
> 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to