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

Home » Public Forums » archive » Re: Sort without loops
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: Sort without loops [message #45165 is a reply to message #45162] Wed, 17 August 2005 03:36 Go to previous message
peter.albert@gmx.de is currently offline  peter.albert@gmx.de
Messages: 108
Registered: July 2005
Senior Member
Hi Ian,

> Is there a clever way of sorting on two fields like this without using a
> loop. The above algorithm is faaaar slower than just using sort.

I don't know how to sort over two fields at the same time, but I could
propose a much faster way ofcreating you new string array, avoiding the
for loop:


spos = strpos(array, ";")

left = strmid($
array, $
transpose(replicate(0, n_elements(array))), $
transpose(spos)$
)

right = string($
fix($
strmid($
array, $
transpose(spos+1)),$
), $
format = '(i4.4)'$
)


The basic idea is to use an array for the variables "first_character"
and "length" in the call to strmid. It has to be the transposed ones,
as the first dimension of those arrays determines how many substrings
are extracted from each element of the string array - one in your case.

On my PC this method is approx. 10 times faster as the for-loop. If it
is still too slow, one could think of providing more sophisticated
arrays for first_character and length with a 2 as first dimension, i.e.
extracting both substrings in one go. But I doubt that this would
really help a lot.

Best regards,

Peter
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: New Tabbing Functionality in IDL 6.2
Next Topic: Re: Postscript Image quality

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

Current Time: Sat Oct 11 17:20:40 PDT 2025

Total time taken to generate the page: 0.00931 seconds