[TIP} co-sort variable 1 based on values in variable 2

Jim Ault JimAultWins at yahoo.com
Wed Mar 21 03:54:08 EDT 2007


On 3/20/07 10:20 PM, "J. Landman Gay" <jacque at hyperactivesw.com> wrote:
> Jim Ault wrote:
>> In your example, the itemoffset(each,varA) will = 0 unless there is an item
>> in varA that matches one in varB.
> 
> Right, I thought that's what you were after. Guess not. I think I still
> haven't groked what you are trying to do, but that's okay -- you
> understand it.

It is pretty simple actually, and here is an example.

Let's say one list you have last names, in another, their telephone numbers
in the same order.  You need to keep two separate lists, but you would like
both sorted to the same order, according to the last names.

In my program, building the lists does not occur in the final desired order,
so a final sort of both lists is required.  The catch is getting the phone
numbers to sort according to the same order as the names.
--this works--
put lastNames into tempNames
split tempNames by cr
sort lines of phNums by tempNames[lineoffset(each,phNums)]
sort lastNames
--now both are in the same order

or in my case, items on a single line in both variables:

split tempNames by comma
sort items of phNums by tempNames [itemoffset(each,phNums)]

Not that you wanted to know,
but the variables in my Rev app are actually two double-nested arrays that
need to be synchronized so that when they become Flash variables, the user
interface performs smoothly and accurately.  "Sort Items" works perfectly.

Jim Ault
Las Vegas





More information about the use-livecode mailing list