Reversing a list
J. Landman Gay
jacque at hyperactivesw.com
Thu Apr 3 01:14:00 EDT 2008
Sarah Reichelt wrote:
> OK people, what's the fastest way to reverse the order of lines in a
> list. I have a list of images gathered together by filtering matching
> files from a set of folders. Now I want to be able to reverse the
> order, but their file names are varied and so I have no obvious way to
> sort them.
>
> I realise I could just use a repeat for each loop and put each one
> before a new list variable, but that seems rather clumsy, and using
> "before" slows down when I have thousands of records.
>
> I'm hoping that Jacque will chime in with one of her custom sort ideas
> that I never can think of, but anyone is welcome to come up with some
> elegant solution.
Does this work:
local tCount
on mouseUp
put fld 1 into tData
put the number of lines in tData into tCount
sort lines of tData by mySort(each)
put tData into fld "results"
end mouseUp
function mySort
subtract 1 from tCount
return tCount
end mySort
Funny you should mention this, because just today I was working on a
handler for this same concept for RevLive.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list