Equinox Online Help - Language Reference - A to Z

Home

ArraySort

Applies to
SyntaxArraySort vector [,column, flags, comparison, start, len]
Action(Statement) Sorts an array according to parameters set.
ScopeUsable anywhere
Notes

VectorExpression may contain an array name or any vector expression. If it contains two or more dimensions, the other columns in the last dimensions may optionally be moved with the sorted data. For this purpose, arrays of more than two dimensions are combined, for example, [2][3][4] would be treated as 6 sortable vectors of 4 elements each.

ColumnExpression parameter specifies which column to sort the array, defaulting to 1.

FlagsExpression may have the following values:

  • 0 Ascending, move all columns with the sorted data
  • 1 Descending, move all columns with the sorted data
  • 2 Ascending, move only the column sorted
  • 3 Descending, move only the column sorted

ComparisonExpression may have the following values:

  • 0 Sort in ASCII order
  • 1 Ignore case when sorting
  • 2 Use SortOrder (telephone directory) order (see the SortOrder function)

StartExpression specifies the beginning of the comparison item inside a string, defaulting to 1.

LengthExpression specifies the length of the comparison item, defaulting to the length of the rest of the string.

StartExpression and LengthExpression are ignored for types other than string.

This statement does not preserve the original order of the array where a number of elements have the same value. If you wish to do this you will need to ensure that no elements have duplicate values.

CategoryArrays
See Also ArrayFind, ArrayFindNext, ArrayGetDimensions, ArraySearch, ArraySearchNext, ArraySetDimensions, ArrayNeg, ArrayNot, Vector, VectorSize
Example

This example sorts a two dimensional numeric array into descending order on the second column, and moves the first column with the sorted data

ArraySort n, 2, 1

This example sorts a string array on the end of the string starting with the fifth character.

ArraySort s, , , , 5

This example creates a numeric array and then passes it to a procedure where it is sorted into ASCII order.

number NumArray[5]
StringSort NumArray

Print NumArray,;; | 1, 10, 120, 2, 4

procedure StringSort String V[]
ArraySort V
end procedure | StringSort