[TIP] Sorting by ValueList and synchronized sorting

Peter Brigham pmbrig at gmail.com
Thu Jun 19 09:56:19 EDT 2008


I believe I discovered that this custom sort function has to be  
modified in one tiny way to work properly. Instead of

sort lines of fld 1 by valueList(word 1 of each)

you have to do

sort lines of fld 1 numeric by valueList(word 1 of each)

The valueList function returns a number, so the sort has to be  
numeric. IIRC, this caused a problem for me until I figured it out. I  
could be misremembering....

Peter M. Brigham
pmbrig at gmail.com


On Jun 17, 2008, at 10:01 PM, use-revolution-request at lists.runrev.com  
wrote:

> Richard Gaskin wrote:
>> I've been looking at this for two days and I can't wrap my head  
>> around it.
>>
>> My understanding of the sort command is that I can tell it to sort  
>> by a
>> particular chunk, and in which direction (ascending or  
>> descending), and
>> by what form of data (numeric or date or text).
>>
>> Indeed, the only examples in the docs are:
>>
>>    sort field "Output"
>>    sort items of myInfo by word 2 of each -- sort by word 2 of the  
>> line
>>    sort lines of field thisField descending numeric by item x of each
>>
>> I've never before seen a sort where the sort specifier is a literal
>> value. :\
>>
>> If I simplify the above to move the function result inline, it would
>> look like:
>>
>>   sort lines of fld 1 by "Monday"
>>
>> What exactly does that do, and how does it do it?
>> And where did you learn how do that?  I can't find anything in the  
>> docs
>> like that.
>
> It's just a custom sort function. Rev evaluates the function before
> sorting each line, so what it is actually sorting by is a number in  
> this
> case. "Each" evaluates to the first word of each line in this case,
> which the function then re-evaluates as the position in the list of  
> days
> of the week. So when "each" is "monday" the sort number is 1. When  
> it's
> Tuesday, the sort number is 2, and so forth.




More information about the use-livecode mailing list