comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Sort
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Sort [message #10313 is a reply to message #10241] Fri, 07 November 1997 00:00 Go to previous messageGo to previous message
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
Peter Suetterlin wrote:
>
> In article <34604767.45FB@dl.ac.uk>,
> Neil Winrow <ncw@dl.ac.uk> writes:
>> Can anybody please offer their help!
>>
>> I have three sets of data, X, Y, Z. I read these sets of data into one
>> big array. I would like to sort one of the sets of data within the big
>> array, lets say sort the Z data. Is it then possible for the
>> corresponding values in the X and Y to also sort to the correct values.
>> Hope someone can understand, and offer me a solution.
>
> ix=sort(Z)
> Z=Z(ix)
> X=X(ix)
> Y=Y(ix)
>
> ... if I understood correct(?)
>
> Peter

So if your big array is created like:

A = [X, Y, Z] ; Nx3
A = transpose(A) ; 3xN

then it will be dimensioned Array[3,n_elements(X)]. So you can
sort it with:

ind_x = sort(A[0,*])

A[0,*] = (A[0,*])(ind_x)
A[1,*] = (A[1,*])(ind_x)
A[2,*] = (A[2,*])(ind_x)

This of course assumes that X,Y and Z all have the same number of
elements.

Dave



--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL style sheet for a2ps
Next Topic: A rant: features vs. programming features

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 11:36:14 PDT 2025

Total time taken to generate the page: 7.92191 seconds