Error Messages/41149


Example message text

The first parameter to SortIndex(«D») is 4-dimensional, so it is ambiguous which dimension should be sorted over.
To remove this ambiguity, you can specify the index to sort over as a second parameter using SortIndex(«D», «I»).

Cause

Let's look at a 2-D example to understand the error message. Suppose Variable A evaluates to:

Variable A :=
I ▶
J
1 2 3 4 5
1 23 12 98 43 23
2 75 23 10 2 88
3 11 12 2 98 55
4 79 3 56 23 18

If we write the following expression, this error will occur:

SortIndex(A)

Notice that the elements of A could be ordered increasing along the I dimension, or they could be ordered increasing along the J dimension. Without an index parameter, there is no way for Analytica to ascertain which dimension to sort over.

Note that the one-parameter variation of SortIndex(D) is slightly different from the two-parameter SortIndex(D,I), in that the one-parameter variation returns an unindexed list (aka implicitly indexed array) while the two parameter returns an array indexed by I. The one-parameter case does not array-abstract - it can only be used when you are guaranteed that another dimension will never be introduced into your parameter. The two parameter usage can deal gracefully with cases where new dimensions are added to your model later.

Remedy

Often this error will expose a mistake elsewhere. If you expected to have a one-D array here, then you'll need to hunt back to find where the extra dimension was introduced and fix the problem there.

If you want to adjust the model to deal with added dimensions, then you need to add the second parameter. You must make sure that the result is treated as an array downstream (specially, that it is not used to define an index).

SortIndex(A, I) →
I ▶
J
1 2 3 4 5
1 2 1 5 4 3
2 4 3 2 1 5
3 3 1 2 5 4
4 2 5 4 3 1

See Also

Comments


You are not allowed to post comments.