[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: error with sort
- Subject: Re: error with sort
- From: landsman(at)my-deja.com
- Date: Mon, 10 Jan 2000 17:46:54 GMT
- Newsgroups: comp.lang.idl-pvwave
- Organization: Deja.com - Before you buy.
- References: <3879D1B0.7444B790@fz-juelich.de> <3879E60C.ABD55B0B@fz-juelich.de> <MPG.12e39968d441aa409899db@news.frii.com> <3879F9A9.E5291846@fz-juelich.de> <MPG.12e3b39d3dcecc0e9899dc@news.frii.com>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:17962
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([1,1,1,1,1])
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[i1]) ;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
Sent via Deja.com http://www.deja.com/
Before you buy.