Command Reference : Matrix Language Reference
  
 
@rapplyranks
Reorder the columns of a matrix using a vector of ranks.
Syntax: @rapplyranks(m, v[, n])
m: matrix, vector
v: vector
n: (optional) integer
Return: matrix, vector
Apply (a row of) column ranks in the vector v to reorder the columns of a matrix m using the ranks.
v should contain unique integers from 1 to the number of columns of m.
If the optional argument n is specified, only the columns in row n will be reordered.
Examples
vector v1 = @ranks(m1.@row(3), "a", "i")
matrix m2 = @rapplyranks(m1, v1)
reorders the columns of the matrix M1 using the ranks in V1. Note that you may use the @ranks function to obtain the ranks of a vector but must obtain unique integer ranking for data with ties through use of the “i” or “r” option in @ranks.
matrix m3 = @rapplyranks(m1, v1, 3)
reorders only the columns in row 3 of M1.
Cross-references
See also @ranks, @capplyranks, @sort, @permute.