Scilab Function

sort - decreasing order sorting

Calling Sequence

[s, [k]]=sort(v)
[s, [k]]=sort(v,'r')
[s, [k]]=sort(v,'c')

Parameters

Description

s=sort(v) sorts v in decreasing order. If v is a matrix, sorting is done columnwise, v being seen as the stacked vector v(:). [s,k]=sort(v) gives in addition the indices of entries of s in v, i.e. v(k(:)) is the vector s.

s=sort(v,'r') sorts the rows of v in decreasing order i.e. each column of s is obtained from each column of v by reordering it in decreasing order. [s,k]=sort(v,'r') returns in addition in each column of k the indices such that v(k(:,i),i)=s(:,i) for each column index i.

s=sort(v,'c') sorts the columns of v in decreasing order i.e. each row of s is obtained from each row of v by reordering it in decreasing order. [s,k]=sort(v,'c') returns in addition in each row of k the indices such that v(i,k(i,:))=s(i,:) for each row index i.

Complex matrices or vectors are sorted w.r.t their magnitude.

y=sort(A) is valid when A is a sparse vector. Column/row sorting is not implemented for sparse matrices.

Examples

See Also