I don't know if this what you wanted,
v {~ /: 2{"1 v

Hahn, Harvey wrote:
I recently downloaded the index to the "Vector" journal archive
<http://www.vector.org.uk/archive/vecindex.zip> in order to learn more
about J from articles there.  The unzipped index is a tab-delimited file
with a current shape of 1081 5 after loading into J.  The current sort
order is by author name, but, for my purposes, I wanted the index sorted
by issue instead (column 2 rather than column 0) and, later on, sorted
by title.  So I did the following:

   vt=. |: v    NB. transpose
   vts1=. /:~ 2{vt    NB. sort the issue "column" (row 2)
   vt2=. /: 2{vt    NB. grade the issue "column" (row 2)

The second line above (vts1) was more a "proof of concept" line (not
production code), just to verify that I was on the right track.  My
problem is that I'm "stuck" on what to do next.  Essentially, I want to
rearrange ALL of the entries for each sorted element on the basis of
vt2, not just row (transposed column) 2.  I tried both of the following
(based on the Dictionary "GradeUp"/"SortUp" entries):

   vts2=. vt2 { vt
   vts2=. vt /: vt2

and neither works (even though they're conceptually what I'm trying to
do).  Let me repeat/clarify my hoped-for end result: it'll require
another transpose at the very end, but the final result should look the
same as the original loaded array except that all of the rows will be in
sorted order by issue (column 2) rather than by author (column 0).  In
other words, I'm trying to figure out how to sort ALL cells in a row (or
column) in "parallel" on the basis of a sorted SINGLE cell in each row
(or column).  I hope I'm making sense.  This is a very practical kind of
thing, so I'm sure there must be something simple that I'm overlooking.

Any insights or guidance?  Thanks in advance!

Harvey

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to