Contents Previous Next Subchapters

Sorting The Rows Of A Matrix By Pointers
Syntax psort(matrix)
See Also sort , pmax , reverse , and psort(matrix, start, width)

Description
Returns an integer column vector containing a ranking of the rows of matrix, where matrix is an integer, real, double-precision, or character matrix. The first element of the returned vector contains the row number of the smallest row in matrix, the second element contains the row number of the next largest, and so on. One row of matrix is considered larger than another in the same sense as in sort(matrix) .

Example
If you enter
     x = {"Baker", "Alpha", "Charlie"}
     p = psort(x)
     print p
O-Matrix will respond
     {
     2
     1
     3
     }
The 2 is the row number of "Alpha", the 1 is the row number of "Baker", and the 3 is the row number of "Charlie". If you continue the previous example by entering
     x(p, :)
O-Matrix will respond
     Alpha
     Baker
     Charlie