Function groups -
sort sorts the rows of a matrix. If column c1 is specified the matrix will be sorted with respect to column c1. That is, the rows of the matrix will be arranged in order that elements of column c1 are in ascending (descending) order.
||z = sort (x, c)
|x ||n x p x d1 x ...x dn array
|c ||m x 1 vector
|z ||n x p x d1 x ...x dn array|
If m>1 then the matrix will be first sorted by column c. Then, will be sorted by column c without changing the order given by c. The process will continue until no further sort is being possible (without changing the previous order) or no more parameters are found.
If c[j] (j=1...m) is positive the sort will be in ascending order. to sort in descending order with respect to c[j] input as parameter -c[j].
To sort every column of matrix x separately use z=sort(x, 0).
x = #(3, 1, 1, 3, 1)~#(4, 5, 4, 2, 4)~#(1, 5, 4, 0, 1)
sort(x', #(-1, 2))
Contents of sort
[1,] 4 5 4 2 4
[2,] 3 1 1 3 1
[3,] 1 5 4 0 1
(C) MD*TECH Method and Data Technologies, 05.02.2006