# AIdx

```AIDX (<array name>)
```

The AIDX internal function returns an array that is an ascending index obtained from sorting the array within parenthesis. The array to be sorted may be either string or numeric. The use of AIDX is permitted only in the MAT statement.

Note that you cannot use the Mat keyword in the array name parameter of this function.

Correct:

```00010 MAT AscendingIndexArray(UDIM(ArrayToBeIndexed\$))=AIDX(ArrayToBeIndexed\$)
```

Incorrect:

```00010 MAT AscendingIndexArray(UDIM(ArrayToBeIndexed\$))=AIDX(MAT ArrayToBeIndexed\$)
```

The program below will sort and print an array of names in alphabetical order:

```00100 DIM A(100),N\$(100)
00110 DATA "Tom", "Colleen", "Bill", "Christi"
00120 DATA "Tim", "Dave", "Sheila", "Jenni"
00130 DATA "Pam", "Laura", "Jean", "Michele"
00140 DATA "Gary", "Gordon", "Mallika"
00150 READ MAT N\$ EOF 155
00155 MAT N\$(CNT)
00160 MAT A(UDIM(N\$))=AIDX(N\$) !
00170 FOR I=1 TO 15
00180    PRINT N\$(A(I))
00190 NEXT I
```

### Related Functions

Other functions that operate on arrays are DIDX (array sort with descending index), SRCH, SUM and UDIM. See also MAT.

### Technical Considerations

1. The RD specification in BRConfig.sys can affect the AIDX function because it determines when two numeric values are considered equal.
2. The COLLATE option in effect when the program was last saved or in the Option (statement) can alter the sort order from the AIDX function when sorting string values.
3. To use AIDX, the arrays on both sides of the equal sign must have only one dimension and they must be the same number of elements.