Command Reference : Matrix Language Reference
Syntax: @capplyranks(m, v[, n])
Argument 1: vector, matrix, or sym, m
Argument 2: vector, v
Argument 3: (optional) integer, n
Return: vector, matrix, or sym
Reorder the rows of a matrix m using the ranks in the vector v. If the optional argument n is specified, only the rows in column n will be reordered. v should contain unique integers from 1 to the number of rows of m.
matrix m2 = @capplyranks(m1, v1)
reorders the rows of the matrix M1 using the ranks in V1, while
matrix m3 = @cappyranks(m1, v1, 3)
reorders only the rows of column 3 of M1.
Note that you may use the @ranks function to obtain the ranks of a vector. Obtaining unique integer ranking for data with ties requires use of the “i” or “r” option in @ranks, as in
vector y = @ranks(x, "a", "i")
See also @ranks, @rapplyranks, @sort, and @permute.