[TIP] Sorting by ValueList and synchronized sorting
Richard Gaskin
ambassador at fourthworld.com
Tue Jun 17 19:52:02 EDT 2008
J. Landman Gay wrote:
> Richard Gaskin wrote:
>>
>> 1. Using a function for a sortKey expression introduces a "sometimes"
>> rule in terms of understanding the order of expression evaluation in the
>> engine, in which most of the time functions are evaluated first but in
>> this case the function is applied repeatedly for each line of the sort
>> container as the sort command is run.
>
> Well, not really. It's more like a substitution for what the engine does
> anyway. When the engine sorts a container, it has to assign a position
> for each element being sorted. A custom sort function does the same
> thing; the engine will use the number returned by the function when
> arranging the elements.
>
> The order of evaluation hasn't changed, and functions are still
> evaluated first. But when sorting, each element has to be evaluated
> individually.
Right. That's what initially threw me.
As far as I can recall, this optional form of the sort command is the
only way to call a function iteratively without using a repeat loop.
Are there others I've forgotten?
It's very handy, but a cognitive hurdle for me at first. I'd never seen
anything like it before.
Anyone else have a mental hiccup when they first encountered this?
--
Richard Gaskin
Managing Editor, revJournal
_______________________________________________________
Rev tips, tutorials and more: http://www.revJournal.com
More information about the use-livecode
mailing list