B = sortrows(A)
B = sortrows(A, col)
[B, index] = sortrows(...)
| Parameter | Description |
|---|---|
| A | array whose rows are sorted. |
| col | column index or vector of column indices. A negative index requests descending order for that key. |
| Parameter | Description |
|---|---|
| B | array with rows sorted according to the selected keys. |
| index | row indices such that B = A(index,:). |
Rows with equal selected keys retain their original order, including descending cell-string keys.
sortrows sorts rows of an array using one or more columns as keys.
Negative column indices request descending order for the corresponding key.
A = [2 3; 1 4; 2 1];
[B, index] = sortrows(A, [1 -2])
| Version | Description |
|---|---|
| 2.0.0 | initial version |