Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!fernwood!uupsi!kepler1!rjfrey From: rjfrey@kepler.com (Robert J Frey) Newsgroups: comp.lang.apl Subject: Re: WANTED: a way to sort array so each column i Message-ID: <565@kepler1.kepler.com> Date: 18 Apr 91 00:30:54 GMT References: <31931@usc> <13APR91.22583472@uc780.umd.edu> Reply-To: rjfrey@kepler1.UUCP (Robert J Frey) Organization: Kepler Financial Management, Ltd., Setauket, NY. Lines: 36 In article weg@convx1.ccit.arizona.edu (Eythan Weg) writes: >In article <13APR91.22583472@uc780.umd.edu> cs450a03@uc780.umd.edu >(Raul Rockwell) writes: > > > A Analla writes: > > >Could some please suggest a generic function to reorder each column > >of an array in descending order where the array is two dimensional. > >Incidentally, how does one write this function in APL2? > >Eythan Weg In Dyalog APL, which is similar to APL2, one could do: A[; gradedown rotate A] This would generalize to simple arrays, character or numeric, of any dimension. If this use of grade(down/up) generalizes like this in APL2, then I might try: A[; gradedown[1] A] because (from what I remember) APL2 is rather general in its use of the axis "operator". I don't know if this last bit works, however. In vanilla APL there are some cases that can be handled pretty simply. For example, if A is a 5 by 10 numeric matrix whose elements are all positive numbers less than or equal to 100, then this does the job: A[; gradedown(5 reshape 100)decode A] This last "solution" has some serious overflow and truncation problems if A results in decoded values which are too large.