1
.TH sort 1 "April 1993" "Scilab Group" "Scilab Function"
4
sort - decreasing order sorting
14
: real or complex vector/matrix; sparse vector; character string vector/matrix
17
: real or complex vector or matrix; sparse vector; character string vector/matrix
20
: vector or matrix of integers
22
\fVs=sort(v)\fR sorts \fVv\fR in decreasing order.
23
If \fVv\fR is a matrix, sorting
24
is done columnwise, \fVv\fR being seen as the stacked vector \fVv(:)\fR.
25
\fV[s,k]=sort(v)\fR gives in addition the indices of entries
26
of \fVs\fR in \fVv\fR, i.e. \fVv(k(:)) \fR is the vector \fVs\fR.
28
\fVs=sort(v,'r')\fR sorts the rows of \fVv\fR in decreasing order i.e.
29
each column of \fVs\fR is obtained from each column of \fVv\fR
30
by reordering it in decreasing order.
31
\fV[s,k]=sort(v,'r')\fR returns in addition in each column of \fVk\fR
32
the indices such that \fVv(k(:,i),i)=s(:,i)\fR for each column index \fVi\fR.
34
\fVs=sort(v,'c')\fR sorts the columns of \fVv\fR in decreasing order i.e.
35
each row of \fVs\fR is obtained from each row of \fVv\fR
36
by reordering it in decreasing order.
37
\fV[s,k]=sort(v,'c')\fR returns in addition in each row of \fVk\fR
38
the indices such that \fVv(i,k(i,:))=s(i,:)\fR for each row index \fVi\fR.
40
Complex matrices or vectors are sorted w.r.t their magnitude.
42
\fVy=sort(A)\fR is valid when \fVA\fR is a sparse vector. Column/row
43
sorting is not implemented for sparse matrices.
46
[s,p]=sort(rand(1,10));
47
//p is a random permutation of 1:10
49
[Asorted,q]=sort(A);A(q(:))-Asorted(:)
53
sort(v,'r') //Does nothing for row vectors