] x=: 10,. 6 [EMAIL PROTECTED] 5
10 1
10 0
10 4
10 2
10 4
10 4
   ] i=: /: /:^:2"1&.|: x
0 1 2 3 4 5
   i{x
10 1
10 0
10 4
10 2
10 4
10 4
   ranking=: i.!.0~ { /:@/:
   ] j=: /: ranking"1&.|: x
1 0 3 2 4 5
   j{x
10 0
10 1
10 2
10 4
10 4
10 4



----- Original Message -----
From: Roger Hui <[EMAIL PROTECTED]>
Date: Thursday, May 17, 2007 3:17 pm
Subject: Re: [Jprogramming] Multi sort

> > For boxed arguments, that's a bit more difficult, but I
> > could use numbers that sort the same way, for example
> > perhaps something like /:^:2"1&.|:  (That would work for
> > a 2 dimensional array, but is probably not quite right for
> > higher dimensions.)
> 
> /:^:2 does not handle ties correctly, but the
> following would:
>   ranking=: i.!.0~ { /:@/:
> More efficient would be to use /: or \: on each
> column depending on whether the sort is up or down. 
> See 
> http://www.jsoftware.com/jwiki/Essays/Inverted_Table#grade_and_sort
> 
> 
> 
> ----- Original Message -----
> From: Raul Miller <[EMAIL PROTECTED]>
> Date: Thursday, May 17, 2007 2:52 pm
> Subject: Re: [Jprogramming] Multi sort
> 
> > On 5/17/07, Roger Hui <[EMAIL PROTECTED]> wrote:
> > > What if the argument is not numeric?
> > 
> > I would use numeric placeholders.
> > 
> > For character arguments, that's fairly simple -- I could
> > use a.i.]
> > 
> > For boxed arguments, that's a bit more difficult, but I
> > could use numbers that sort the same way, for example
> > perhaps something like /:^:2"1&.|:  (That would work for
> > a 2 dimensional array, but is probably not quite right for
> > higher dimensions.)
> > 
> > Hypothetically speaking, the boxed mechanism would
> > also work for character args (though not so fast).
> > 
> > And, if I wanted something fully general, I guess I'd have to
> > make myself a verb which distinguishes these types to
> > control an agenda.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to