|
Contents | Previous | Next | Subchapters |
| Syntax |
sort(matrix) |
| See Also | psort , mlsort , reverse sort(matrix, start, width) |
sort function can be used to sort the elements of
a column vector.
If you enter
x = {1, 3, 2}
sort(x)
O-Matrix will respond
{
1
2
3
}
The sort function can also be used to sort the rows of a matrix.
If you enter
x = {[2, 1], [1, 2], [1, 1]}
sort(x)
O-Matrix will respond
{
[ 1 , 1 ]
[ 1 , 2 ]
[ 2 , 1 ]
}
Note that when two rows have equal first elements,
the second element of each row determines which row is greater.
If the second elements are equal, the sort function
then looks at the third element, and so on.
To sort in descending order, use the reverse
function.