[TIP] Sorting by ValueList and synchronized sorting
Mark Smith
mark at maseurope.net
Tue Jun 17 18:42:06 EDT 2008
Richard, if you look at the 'valueList' function, it returns a number
ie. the offset of a weekday name into the list of weekday names. It's
this value that is being used to sort the list. It's like attaching a
temporary value to each line and sorting by that.
If there were more than 9 weekdays, this example would have needed to
specify numeric.
This is why you can sort by random(someBigNumber) to randomize a list
- each line effectively gets a random number, and is sorted by it.
Best,
Mark
On 17 Jun 2008, at 22:49, Richard Gaskin wrote:
> 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
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list