sortrows
年代ort rows of matrix or table
年代yntax
Description
sortsB
= sortrows(A
,column
)A
based on the columns specified in the vectorcolumn
.For example,sortrows(A,4)
sorts the rows ofA
in ascending order based on the elements in the fourth column.sortrows(A,[4 6])
first sorts the rows ofA
based on the elements in the fourth column, then based on the elements in the sixth column to break ties.
sorts the rows ofB
= sortrows(___,direction
)A
in the order specified bydirection
for any of the previous syntaxes.direction
can be'ascend'
(default) for ascending order or'descend'
for descending order.direction
can also be a cell array whose elements are'ascend'
and'descend'
, where each element corresponds to a column thatsortrows
在操作。For example,sortrows(A,[4 6],{'ascend' 'descend'})
sorts the rows ofA
in ascending order based on the fourth column, then in descending order based on the sixth column to break ties.
sorts the rows of a table in ascending order based on the values in the first variable. If elements in the first variable are repeated, then结核病lB
= sortrows(结核病lA
)sortrows
sorts by the elements in the second variable, and so on.
If结核病lA
is a timetable, thensortrows
sorts the rows of结核病lA
in ascending order based on its row times. Row times of a timetable label the rows along the first dimension of the timetable.
sorts a table based on its row names. Row names of a table label the rows along the first dimension of the table. If结核病lB
= sortrows(结核病lA
,'RowNames')结核病lA
does not have row names, that is, if结核病lA.Properties.RowNames
is empty, thensortrows
returns结核病lA
.
This syntax is not supported when结核病lA
is a timetable.
sorts结核病lB
= sortrows(结核病lA
,rowDimName
)结核病lA
by row labelsrowDimName
along the first dimension.
If
结核病lA
is a table, then row labels are row names.If
结核病lA
is a timetable, then row labels are row times.
sorts a table by the elements in the variables specified by结核病lB
= sortrows(结核病lA
,vars
)vars
.For example,sortrows(tblA,{'Var1','Var2'})
first sorts the rows of结核病lA
based on the elements inVar1
, then by the elements inVar2
.
If
结核病lA
is a table and it has row names, thenvars
can include the row names.If
结核病lA
is a timetable, thenvars
can include the row times.
sorts结核病lB
= sortrows(___,direction
)结核病lA
in the order specified bydirection
for any of the previous table syntaxes.direction
can be'ascend'
or'descend'
, which is applied to all specified variables, row names, or row times thatsortrows
在操作。direction
can also be a cell array whose elements are'ascend'
and'descend'
, where each element corresponds to the specified variables, row names, or row times being sorted on.