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 #10243 is a reply to message #10241] Wed, 05 November 1997 00:00 Go to previous messageGo to previous message
savoie is currently offline  savoie
Messages: 68
Registered: September 1996
Member
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.

Neil,

I think you're looking for something like this?


IDL> x = indgen(10)
IDL> y = indgen(10) * 2
IDL> z = randomu(seed,10) *10
IDL> print, x
0 1 2 3 4 5 6 7 8
9
IDL> print, y
0 2 4 6 8 10 12 14 16
18
IDL> print, z
9.42273 7.87034 6.82765 2.36464 2.45571 3.17787
0.410162 3.58485 0.540125 7.87818

IDL> sortindex = sort(z)
IDL> print, sortindex
6 8 3 4 5 7
2 1 9 0
IDL> print, z(sortindex)
0.410162 0.540125 2.36464 2.45571 3.17787 3.58485
6.82765 7.87034 7.87818 9.42273
IDL> print, x(sortindex)
6 8 3 4 5 7 2 1 9
0
IDL> print, y(sortindex)
12 16 6 8 10 14 4 2 18
0

The key is that the IDL sort routine returns an array of indices into
the array to be sorted. So that by using the array subscripted by the
indices, you get the sorted array.

Hope this helps.
matthew

--
Matthew H. Savoie Systems Technology Associates
Systems Analyst Supporting NOAA Profiler Network
ph. 303.497.6642 Demonstration Division/FSL/ERL
mailto: savoie@fsl.noaa.gov <URL:http://www-dd.fsl.noaa.gov/online.html>
[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 15:46:35 PDT 2025

Total time taken to generate the page: 1.84195 seconds