Sorting array

David Vaughan dvk at dvkconsult.com.au
Tue Dec 20 00:49:51 EST 2005


On 20/12/2005, at 12:27, Brad Borch <brad at activadesign.com> wrote:
>
<snip>
>  Flash will be reading what is
> essentially a tab-delimited database.
>
> First, am I better off dropping text into an array in Rev to edit  
> it, or
> simply sorting and managing the text as a big hunk of text?
>
> Second, if the array is better, how do I sort the array? (I've already
> built the Rev tool to split the text into the array). I've tried "sort
> gMyEvents numeric by item 1 of each" (after defining the itemDelimiter
> as tab). Is there a simple way to sort an array? Am I missing  
> something?

You could manage a tab-delimited list as suggested but if it is  
otherwise useful to have array access then you need an answer to that  
question, sorting an array.
Answer: You don't; you just access it in sorted order.
Explanation: Take an array flashData
   put the keys of flashData into fKeys
   sort fKeys
   repeat for each line fk in fKeys
     doSomething flashData[fk]
     etc

This way you still have your array with direct key access and also  
can iterate through it in sorted order as desired.

HTH

regards
David



More information about the use-livecode mailing list