sorti sorts a real, complex or string matrix or vector in ascending order and returns an index vector of the sorted matrix.
Return Value
rvSortIndex is a index vector of the sorted matrix.
Parameters
mUnsorted is the unsorted matrix. The first column will be sorted.
options is a OR combination of the following values:
| SORT_REVERT (1) | Sort in descending order. Default ascending order. |
| SORT_CASE (2) | Case sensitive sorting (only for string vectors/matrices). Default: sorti ignores case. |
Example
* srand("test")
1.0000
* a = rand(3,3)
* a
0.5536 0.7214 0.6267
0.0735 0.9892 0.8892
0.4024 0.0891 0.5894
* sorti(a) // sort first column
2.0000
3.0000
1.0000
* // sort second column
* sorti(a[;2])
3.0000
1.0000
2.0000
* // sort third column
* a = a[sorti(a[;3]);]
* a
0.4024 0.0891 0.5894
0.5536 0.7214 0.6267
0.0735 0.9892 0.8892
History
| Version | Description |
|---|---|
| 5.0.0 | New parameter options. |
id-1715870