[kepler-users] Sort Multidimensional Array

Christopher Brooks cxh at eecs.berkeley.edu
Mon Jan 30 09:04:02 PST 2012


Hi Muhannad,
It would probably be best if you wrote a Java actor that did such an 
operation.
The Ptolemy II expression language includes a sort() operation that 
works on numeric ArrayTokens (except for complex).

The Interpolator and Pulse actors are close to what you want, but the 
index parameter must be increasing in value and the index parameter is a 
parameter, not a PortParameter.

The way I would approach this is to create a new actor that read in two 
tokens, A1 and A2, from ports, performed the operation and created a new 
token and outputted the new token.

_Christopher

On 1/29/12 3:35 PM, Ali, Muhannad wrote:
> Hello,
>
> is there any way to sort a multi-dimensional array according to some column, e.g. sort(A, j). Or if I have two one-dimensional arrays A1, A2 and after sorting A1, I need that A2's elements that correspond to A1's ones have the updated indices like A1.
>
> Example:
>
> A1 = {2, 0, 3, 1}
> A2 = {"x2", "x0", "x3", "x1"}
>
> After sorting A1 (say descending), I need that A2 looks like that: A2={"x3", "x2", "x1", "x0"}
>
>
> Thanks!
>
> Best regards,
>
> Muhannad
> _______________________________________________
> Kepler-users mailing list
> Kepler-users at kepler-project.org
> http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users

-- 
Christopher Brooks, PMP                       University of California
CHESS Executive Director                      US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust        Berkeley, CA 94720-1774
ph: 510.643.9841                                (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 cell: 707.332.0670



More information about the Kepler-users mailing list