apologize if this has been asked before.
for the inverted data,
]s=: (,.?.30#2) ; (,.?.30#6) ; (_3]\a.{~65+?.90#26) ; (,.?.30#20)
+-+-+---+--+
|0|0|KDD| 6|
|1|5|GYL|15|
|0|5|ENK|19|
|1|4|CSG|12|
|1|2|PAB|14|
|1|3|QMK|19|
|0|2|YSD| 0|
|0|1|QYM|17|
|0|4|WFP| 0|
|1|2|DMY|14|
|0|0|XRC| 6|
|1|2|QAT|18|
|0|1|LLB|13|
|0|4|DJY|18|
|1|1|PND|11|
|0|2|GYR|12|
|0|4|ZTH|18|
|0|0|UJG| 0|
|0|4|HBR|10|
|0|0|BUD| 2|
|1|5|TVE|11|
|1|4|LPA|16|
|1|0|JRT| 0|
|0|0|NXF| 4|
|0|0|GPW| 4|
|0|5|ANS|11|
|0|1|FHK|13|
|0|5|AMT| 3|
|1|0|SHH|16|
|1|4|ZLS| 6|
+-+-+---+--+
I want to sort the s with the first three columns, the primary key is the first,
secondary key the second etc. I do this by sorting successively (sorting in j is
stable),
'a b c d'=. s
'a b c d'=. (a/:c) ; (b/:c) ; (c/:c) ; (d/:c)
'a b c d'=. (a/:b) ; (b/:b) ; (c/:b) ; (d/:b)
'a b c d'=. (a/:a) ; (b/:a) ; (c/:a) ; (d/:a)
a ; b ; c ; d
+-+-+---+--+
|0|0|BUD| 2|
|0|0|GPW| 4|
|0|0|KDD| 6|
|0|0|NXF| 4|
|0|0|UJG| 0|
|0|0|XRC| 6|
|0|1|FHK|13|
|0|1|LLB|13|
|0|1|QYM|17|
|0|2|GYR|12|
|0|2|YSD| 0|
|0|4|DJY|18|
|0|4|HBR|10|
|0|4|WFP| 0|
|0|4|ZTH|18|
|0|5|AMT| 3|
|0|5|ANS|11|
|0|5|ENK|19|
|1|0|JRT| 0|
|1|0|SHH|16|
|1|1|PND|11|
|1|2|DMY|14|
|1|2|PAB|14|
|1|2|QAT|18|
|1|3|QMK|19|
|1|4|CSG|12|
|1|4|LPA|16|
|1|4|ZLS| 6|
|1|5|GYL|15|
|1|5|TVE|11|
+-+-+---+--+
There should be other better method, eg, can it be done using permutation
vectors?
--
regards,
bill
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm