Think of something that you wish Authorware could do but it doesn't?  Let the our good friends at Macromedia know via the wishlist.

Please let us know if you find any of the materials on this site inappropriate or offensive. Please include the url and why the material should be reviewed.

Comments and questions about the site are also welcome. Please no Authorware questions, use the AWARE list.


1063 - Can 10 lists can be sorted using SortByValue?

by - Joseph Ganci

The docs imply that up to10 lists can be sorted using SortByValue, but
with 10 lists and the "order" parameter AW thinks it's 11 lists! This is
what I want to do:

SortByValue(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, 1)

Have I made a mistake?

I just checked it out. I don't think that Authorware thinks there are 11 lists. Rather, Authorware is limiting the number of arguments to 10, which means you can either have 10 lists as arguments, at which point Authorware will assume you want the sort in ascending order, or have 9 lists and the last argument set to FALSE or 0 to force a descending order. I wouldconsider this a bug in the function.

It's important to note for those who don't know that this function does not sort each list separately in ascending or descending order. It only sorts the first list, but it keeps the other lists synchronized. That means if you have two lists:

a1 := [2,3,1]
a2 := [1,2,3]

and you use

SortByValue(a1, a2)

the results will be

a1 = [1,2,3]
a2 = [3,1,2]

Note that the value 3 in a2 is still synchronized with the value 1 in a1, as it was to begin with. Both were in position 3 before the sort, now they're both in position 1. That's a beautiful feature of the SortByValue function. One application is to have data stored in different lists that need to stay synchronized, such as names in one lists and phone numbers in another list, id numbers in a third list, and so on up to 10 fields in 10 separate lists. If someone wants to sort the names, you can keep all the lists synchronized with the names list:

SortByValue(names, idnumbers, phones, ...)

If someone want to sort by phones, use the same approach, only make phones first:

SortByValue(phones, names, idnumbers, ...)

Note that the order in which you place the lists to synchronize, outside the first one, does not matter.

This is also why the function requires that all the lists have the same number of indices. It cannot obviously synchronize lists of different lengths. Remember, the only list that is sorted the first time is a1. The others are merely synchronized, they are are not considered sorted, so you could sort by those lists later, e.g. do the above sorts one after the other.

There are 0 reviews
Add your review