parallel sort question

Jim Ault JimAultWins at yahoo.com
Mon Mar 6 21:15:37 EST 2006


On 3/6/06 1:49 PM, "J. Landman Gay" <jacque at hyperactivesw.com> wrote:

> Jim Ault wrote:
>> Sorting by another field.  Parallel sort question
>> Is there an easy syntax for using the sort lines to do parallel sorting
> 
> There is nothing built-in, but I've used this:
> local lKeyData, lLineCounter
> 
> on sortBy keyField -- parallel sorting of linked flds
>    put fld keyField into lKeyData
>    put "data1,data2,data3" into dataFields -- fill in your fld names here
>    repeat with i = 1 to the number of items of dataFields
>      put 0 into lLineCounter
>      sort lines of fld (item i of dataFields) by key()
>    end repeat
> end sortBy
> 
> function key
>    add 1 to lLineCounter
>    return line lLineCounter of lKeyData
> end key
> 
Thanks for the response.
In my current case, fld 2 has short, one-word 'tags', so
-----------
get fld listToSort
repeat with x = 1 to the number of lines in it
   put line x of fld 2 & " " before line x of it
end repeat
sort it descending by word 1 of each
repeat for each line LNN in it
   put word 2 to -1 of LNN & CR after finalOrder
end repeat
delete last char of finalOrder
put it into fld listToSort
---------
Which is fast enough for my very small data blocks.
My next task this evening is waaay more data to sort.

Thanks,

Jim Ault
Las Vegas





More information about the Use-livecode mailing list