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 
Switch to threaded view of this topic Create a new topic Submit Reply
error with sort [message #18456] Mon, 10 January 2000 00:00 Go to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Hi,

SORT() is not platform independent!!!!!


Try this:


** Structure !VERSION, 5 tags, length=40:
ARCH STRING 'x86'
OS STRING 'Win32'
OS_FAMILY STRING 'Windows'
RELEASE STRING '5.2'
BUILD_DATE STRING 'Oct 30 1998'

OR

* Structure !VERSION, 5 tags, length=40:
ARCH STRING 'x86'
OS STRING 'Win32'
OS_FAMILY STRING 'Windows'
RELEASE STRING '5.3'
BUILD_DATE STRING 'Nov 11 1999'


a=[1,1,1,1,1]
idx=sort(a)
PRINT,idx

1 2 3 4 0


b=['A','B','C','D','E']
PRINT,b[idx]

B C D E A


** Structure !VERSION, 5 tags, length=40:
ARCH STRING 'ibmr2'
OS STRING 'AIX'
OS_FAMILY STRING 'unix'
RELEASE STRING '5.2.1'
BUILD_DATE STRING 'Jun 4 1999'


a=[1,1,1,1,1]
idx=sort(a)
PRINT,idx

1 0 2 4 3


b=['A','B','C','D','E']
PRINT,b[idx]

B A C E D



================================================


R.Bauer
  • Attachment: R.Bauer.vcf
    (Size: 0.00KB, Downloaded 80 times)
Re: error with sort [message #18568 is a reply to message #18456] Thu, 13 January 2000 00:00 Go to previous message
Julie Greenwood is currently offline  Julie Greenwood
Messages: 6
Registered: December 1999
Junior Member
Martin Schultz <martin.schultz@dkrz.de> wrote in message
> 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.

It seems to now be at:
http://www-as.harvard.edu/people/staff/mgs/idl/

Julie

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Juliet G. Greenwood
Senior Programmer
Oceanweather Inc.
JulieG@Oceanweather.com
http://www.oceanweather.com/

http://www.thehungersite.com/
The Hunger Site - Donate Food for Free to
Feed Hungry People in the World.
The Site's Sponsors Make the Donations.
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 [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Wed Oct 08 22:09:54 PDT 2025

Total time taken to generate the page: 0.95854 seconds