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

Home » Public Forums » archive » error with 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: error with sort [message #18569 is a reply to message #18456] Thu, 13 January 2000 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
landsman@my-deja.com wrote:
>
> If you are worried about what SORT does to equal values, you might
> instead want to use the program bsort.pro, available at
>
> ftp://idlastro.gsfc.nasa.gov/pub/pro/misc/bsort.pro
>
> This procedure ensures that equal values are always maintained in the
> initial order, i.e.
>
> IDL> print,bsort()
> 0 1 2 3 4
>
> One place where this procedure is useful is when you are sorting on more
> than one parameter. For example, suppose you have a set of
> temperature and pressure measurements (T, P), and want the primary sort
> to be by temperature -- but whenever temperatures are equal, you want
> the values sorted by pressure. One can do this as follows:
>
> i1 = sort(P) ;Secondary sort on pressure
> i2 = bsort(T) ;primary sort on temperature
>
> and i2 will give the desired indexing.
> Of course, BSORT will be slower than the intrinsic SORT function.
>
> Wayne Landsman landsman@mpb.gsfc.nasa.gov

For this purpose, I have written a multisort routine that is (hopefully)
still available at
http://www-as.harvard.edu/chemistry/trop/staff/mgs/idl
This allows "hierarchical" sorting for (I believe) up to 5 variables.

Usage: multisort,array,index= [,revert=[0,1,0] ]
to sort a >= 3-dimensional array for primary key 'column 2', secondary
key 'column 1' and tertiary key 'column 3'. The revert option allows you
to do an inverse sort for any hierarchy level.

I'd be interested to know how multisort performs compared to the bsort
method you proposed.

Cheers,
Martin

--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Using MSVC++ 4.2 to create DLL for CALL_EXTERNAL
Next Topic: Re: IDL Shareware -- Gov't Labs

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

Current Time: Sat Oct 11 10:38:12 PDT 2025

Total time taken to generate the page: 1.03970 seconds