Rearranges the columns or rows of the current matrix object according to a permutation index.
MatrixObject.ReorderCols PermIndex MatrixObject.ReorderRows PermIndex
Error 1304 is returned if PermIndex parameter does not contain a valid array.
Private Sub MatrixSortReorderRows()
Dim A As Matrix, B As Matrix
Dim PI As Variant
Set A = New Matrix
A.Size 6, 6
A.FillRandom
Set B = New Matrix
B.Size 6, 1
B.FillRandom
Debug.Print "A = "
Debug.Print A.GetString
Debug.Print "B = "
Debug.Print B.GetString
A.SortRows 0, msoAscending, PI
B.ReorderRows PI
Debug.Print "A sorted"
Debug.Print A.GetString
Debug.Print "B reordered"
Debug.Print B.GetString
End Sub
A = | 6.000 2.000 8.000 6.000 5.000 4.000 | | 9.000 8.000 7.000 2.000 9.000 7.000 | | 5.000 3.000 0.000 1.000 4.000 1.000 | | 2.000 10.000 4.000 1.000 0.000 0.000 | | 4.000 5.000 6.000 6.000 6.000 2.000 | | 7.000 5.000 4.000 1.000 6.000 8.000 | B = | 5.000 | | 3.000 | | 9.000 | | 7.000 | | 10.000 | | 9.000 | A sorted | 2.000 10.000 4.000 1.000 0.000 0.000 | | 4.000 5.000 6.000 6.000 6.000 2.000 | | 5.000 3.000 0.000 1.000 4.000 1.000 | | 6.000 2.000 8.000 6.000 5.000 4.000 | | 7.000 5.000 4.000 1.000 6.000 8.000 | | 9.000 8.000 7.000 2.000 9.000 7.000 | B reordered | 7.000 | | 10.000 | | 9.000 | | 5.000 | | 9.000 | | 3.000 |