Description
Sorts the matrix in the order of the columns specified. Example: matrix.Sort({0, 1, 2}, {1, -1, 1}) sorts by the first column ascending, then the second descending, then the third ascending. When FreeFlyer sorts by the column the rows will remain grouped during the sorting. If there are two numbers in the column with the same value, then FreeFlyer will keep the rows grouped and sort by the value of the next column.
Timing Precision Mode
This page describes functionality in nanosecond timing precision mode.
Click here to see the documentation for this object in millisecond timing precision mode.
Method Signature
Matrix.Sort(
|
Array sortColumn,
|
|
Array sortDirection)
|
Arguments
sortColumn
|
|
Description:
|
The columns which determine the sort order. Ex: {0, 1, 2} sorts by the first column, then the second, then the third.
|
Required Size:
|
At least 1
|
sortDirection
|
|
Description:
|
Specifies ascending or descending sort order with 1 or -1.
|
Required Size:
|
At least 1
|
Syntax
myMatrix1.Sort(myArray1, myArray2);
|
This example demonstrates how to sort a 4 x 3 Matrix.
Matrix myMatrix(4,3);
myMatrix = [5, 6, 4;
3, 9, 7;
3, 1, 2;
3, 9, 3];
// The following sorts the matrix rows by ascending by
// the first column, then by descending by the second
// column, and then by ascending by the third column.
myMatrix.Sort({0, 1, 2}, {1, -1, 1});
Report myMatrix;
|
Output:
myMatrix =
3.0
|
9.0
|
3.0
|
3.0
|
9.0
|
7.0
|
3.0
|
1.0
|
2.0
|
5.0
|
6.0
|
4.0
|
|
|
See also
Matrix Object
Matrix, Array, and Variable Math Guide
|