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

Home » Public Forums » archive » Multi-column 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: Multi-column sort [message #79497 is a reply to message #79404] Thu, 01 March 2012 14:02 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
You might look at Craig Markwardt's multisort

http://cow.physics.wisc.edu/~craigm/idl/down/multisort.pro

On Thursday, March 1, 2012 10:02:06 AM UTC-5, Percy Pugwash wrote:
> I would like to sort a 2D string by column, specifying primary,
> secondary and further sort criteria (i.e. rows which are equal based
> on criterion 1 are sorted by criterion 2).
>
> Is there any neat way to do this in IDL?
>
> I'd thought of using the following:
>
> tosort = [3,1,5] ; Sort by column 3, then 1, then 5
> maxlen = max(strlen(sortarray[tosort,*])) ; Length of longest string
> paddedarray =
> string(sortarray[tosort,*],format='(a'+string(maxlen,format= '(i0)') +
> ')' ) ; Pad all strings to match longest length
> concatarray = paddedarray[0,*]
> for i = 0, n_elements(tosort)-1 do concatarray += paddedarray[i,*] ;
> Concatenate strings across columns
> indices = sort(concatarray) ; Sort the concatenated strings
>
> However, this method does not allow me to specify which direction the
> sort should go for each of the sort columns. Can anyone think of a way
> to extend the method to allow this (or a completely different method
> which achieves the same effect!)?
>
> Thanks,
>
> P
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How 2 show animations.
Next Topic: Re: Read Andor CCD camera .sif file format in IDL?

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

Current Time: Sat Oct 18 20:35:31 PDT 2025

Total time taken to generate the page: 0.02313 seconds