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

Home » Public Forums » archive » Re: Sorting (big) int array: Eliminate for loop
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 (big) int array: Eliminate for loop [message #68047] Tue, 22 September 2009 05:15 Go to previous message
Luds is currently offline  Luds
Messages: 7
Registered: September 2009
Junior Member
On Sep 21, 5:37 pm, greg <greg.a...@googlemail.com> wrote:
> How about this...
>
> pro test
>  a=['I','E','F','D','A','J','C','B','G','H']
>  b=['E','B','I','J','D','A','C','H','F','G']
>
>  qa=sort(a)
>  qb=sort(b)
>  qa2=sort(qa)
>  elements=qb[qa2]
>
>  print,b[elements]
> end
>
> IDL> test
> I E F D A J C B G H
>
> Sortingthe sorted indices is the trick. I think it's right, but it
> makes my head hurt anyway.
>
> regards,
> Greg

Perfect, thanks. This works great. Having to do a couple sorts doesn't
add too much overhead to my code. It's much faster now.

By the looks of it the value_locate function could do the trick too,
but it seems to want one of the arrays sorted anyway, which isn't the
case for me.

Thanks for the advice guys. Very helpful.

A
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: passing parameters to .sav file in IDL VM
Next Topic: Re: HDF: accessing VData in VGroup

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

Current Time: Wed Oct 08 19:09:45 PDT 2025

Total time taken to generate the page: 0.00491 seconds