[TIP] Sorting by ValueList and synchronized sorting

Richard Gaskin ambassador at fourthworld.com
Tue Jun 17 17:49:14 EDT 2008


Hugh Senior wrote:
> Have you needed to sort lists by a value list or synchronize different 
> lists, but thought it not easily do-able in Rev? You may find the following 
> tips useful.
> 
> In a field, type some lines where the first word is a random day of the 
> week, then...
> 
> on mouseUp
>   sort lines of fld 1 by valueList(word 1 of each)
> end mouseUp
> 
> function valueList what
>   put "Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday" into tList
>   return itemOffset(what,tList)
> end valueList

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.

TIA -

-- 
  Richard Gaskin
  Managing Editor, revJournal
  _______________________________________________________
  Rev tips, tutorials and more: http://www.revJournal.com



More information about the use-livecode mailing list