Reversing a list
Sarah Reichelt
sarah.reichelt at gmail.com
Thu Apr 3 20:14:50 EDT 2008
And the winner is.......
Jacque (with one modification).
local tCount
function reverseList pList
put the number of lines in pList into tCount
sort lines of pList by mySort()
return pList
end reverseList
function mySort
subtract 1 from tCount
return tCount
end mySort
I had thought that Jacque's must be faster than Jan's because Jan's
does more operations per cycle, but it was a bit slower. Then I
noticed that Jacque had used "sort lines of pList by mySort(each)"
where Jan had left out the "each". Deleting the "each" from Jacque's
function made it the fastest. Fractionally faster than Jan's, it takes
about 2/3 of the time of Mark's solution using arrays, and it way
faster than the string method.
Thanks everyone - fun and instructive :-)
Cheers,
Sarah
More information about the use-livecode
mailing list