Sort
Sort array elements in ascending or descending order
Syntax
sort(x) |
x is a row/column real vector or real matrix |
If x is a vector, sort(x) sorts the elements of x. If x is a matrix, sort(x) sorts the rows of x. |
sort(x, n) |
x is real matrix n is 1 or 2 |
sort(x, 1) sorts the rows of x. sort(x, 2) sorts the columns of x. |
sort(x, mode) |
x is real row/column vector or real matrix mode is a string of ‘ascend’ or ‘descend’ |
If mode is 'ascend', x is sort in ascending order. If mode is 'descend', x is sort in descending order |
sort(x, n, mode) |
x is real matrix n is 1 or 2 mode is a string of ‘ascend’ or ‘descend’ |
sort(x, n, mode) sorts x for rows (if n = 1) or columns (if n = 2) in ascending order (if mode='ascend') or descending order (if mode='descend') |
Examples
Input |
Output |
x=[1,4,3,2] sort(x) |
|
x=[1;4;3;2] sort(x) |
|
x=[3,7,5;0,4,2] sort(x) |
|
x=[3,7,5;0,4,2] sort(x,1) |
|
x=[3,7,5;0,4,2] sort(x,2) |
|
x=[1,4,3,2] sort(x,'ascend') |
|
x=[1,4,3,2] sort(x,'descend') |
|
x=[3,7,5;0,4,2] sort(x,'ascend') |
|
x=[3,7,5;0,4,2] sort(x,'descend') |
|
x=[3,7,5;0,4,2] sort(x,1,'ascend') |
|
x=[3,7,5;0,4,2] sort(x,1,'descend') |
|
x=[3,7,5;0,4,2] sort(x,2,'ascend') |
|
x=[3,7,5;0,4,2] sort(x,2,'descend') |
Created with the Personal Edition of HelpNDoc: Write EPub books for the iPad