| Statistics Toolbox™ | ![]() |
B = sort(A)
B = sort(A,dim)
B = sort(A,dim,mode)
[B,I] = sort(A,...)
B = sort(A), when A is an ordinal vector, sorts the elements of A in ascending order. For ordinal matrices, sort(A) sorts each column of A in ascending order. For N-D ordinal arrays, sort(A) sorts the along the first nonsingleton dimension of A. B is an ordinal array with the same levels as A.
B = sort(A,dim) sorts A along dimension dim.
B = sort(A,dim,mode) sorts A in the order specified by mode. mode is 'ascend' for ascending order, or 'descend' for descending order.
[B,I] = sort(A,...) also returns an index matrix I. If A is a vector, then B = A(I). If A is an m-by-n matrix and dim is 1, then B(:,j) = A(I(:,j),j) for j = 1:n.
Elements with undefined levels are sorted to the end.
Sort the columns of an ordinal array in ascending order:
A = ordinal([6 2 5; 2 4 1; 3 2 4],...
{'lo','med','hi'},[],[0 2 4 6])
A =
hi med hi
med hi lo
med med hi
B = sort(A)
B =
med med lo
med med hi
hi hi hi![]() | sobolset | sortrows | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |