Reverse a list
bobsneidar at iotecdigital.com
Mon Feb 16 11:09:55 EST 2015
Ah. Because the keys of an array are effectively a system of pointers in themselves. It might actually be slightly quicker, since the array has already been created, while the For Each will have to create the pointers on the fly at the start of the loop. I’d be curious to find out how much time the pointer creation takes as opposed to the actual loop time.
On Feb 15, 2015, at 04:56 , Dave Cragg <dave.cragg at lacscentre.co.uk<mailto:dave.cragg at lacscentre.co.uk>> wrote:
The advantage of "repeat for each" is when iterating over chunks in a string. (repeat for each line/item/word) In this case, we’re iterating over array elements, and so there is no advantage. If you look back at my earlier version which iterated through array elements from last to first, you’ll see it is basically doing the same as your reverseSort, and the times are also the same.
More information about the Use-livecode