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

Home » Public Forums » archive » Re: sorting column arrays
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: sorting column arrays [message #49154] Fri, 30 June 2006 09:15 Go to previous message
cgguido is currently offline  cgguido
Messages: 195
Registered: August 2005
Senior Member
> The last line makes the sort in one go, since SORT doesn't guarantee
> anything about the order of identical elements. You might have to
> adjust the coefficients if your data has a wider range than the sample
> you show.

sort does indeed tend to jumble things up a little, but bsort does the
job right:
http://www.dfanning.com/tips/sort.html.

also, something like this should work....

IDL> d = $
IDL> [[4, 7, 0, 1], $
IDL> [3, 6, 2, 9],$
IDL> [2, 2, 0, 2],$
IDL> [42, 4, 2, 7],$
IDL> [256, 3, 0, 2],$
IDL> [34, 2, 1, 5]]
IDL>
IDL> s1 = bsort(d[1, *])
IDL> s2 = bsort(d[3, s1])
IDL> s3 = bsort(d[2, s1[s2]])
IDL> sd = d[*, s1[s2[s3]]]
IDL>
IDL> print, d, 'sorted by columns 2>3>1', sd
4 7 0 1
3 6 2 9
2 2 0 2
42 4 2 7
256 3 0 2
34 2 1 5
sorted by columns 2>3>1
4 7 0 1
2 2 0 2
256 3 0 2
34 2 1 5
42 4 2 7
3 6 2 9


Gianguido
[Message index]
 
Read Message
Read Message
Previous Topic: IDL's THIN function, with /PRUNE option
Next Topic: Problem when reading many HDF-EOS file

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

Current Time: Fri Oct 10 06:41:25 PDT 2025

Total time taken to generate the page: 0.64218 seconds