Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

 Function: sort Description: 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.

 Usage: z = sort (x, c) Input: x n x p x d1 x ...x dn array c m x 1 vector Output: z n x p x d1 x ...x dn array

Note:
If m>1 then the matrix will be first sorted by column c[1]. Then, will be sorted by column c[2] without changing the order given by c[1]. 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).

Example:
```x  = #(3, 1, 1, 3, 1)~#(4, 5, 4, 2, 4)~#(1, 5, 4, 0, 1)
sort(x', #(-1, 2))

```
Result:
```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