~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to man/elementary/sort.man

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.TH sort 1 "April 1993" "Scilab Group" "Scilab Function"
 
2
.so ../sci.an
 
3
.SH NAME
 
4
sort - decreasing order sorting
 
5
.SH CALLING SEQUENCE
 
6
.nf
 
7
[s, [k]]=sort(v)
 
8
[s, [k]]=sort(v,'r')
 
9
[s, [k]]=sort(v,'c')
 
10
.fi
 
11
.SH PARAMETERS
 
12
.TP
 
13
 
14
: real or complex vector/matrix; sparse vector; character string vector/matrix
 
15
.TP
 
16
s
 
17
: real or complex vector or matrix; sparse vector; character string vector/matrix
 
18
.TP
 
19
k
 
20
: vector or matrix of integers
 
21
.SH DESCRIPTION
 
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.
 
27
.LP
 
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.
 
33
.LP
 
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.
 
39
.LP
 
40
Complex matrices or vectors are sorted w.r.t their magnitude.
 
41
.LP
 
42
\fVy=sort(A)\fR is valid when \fVA\fR is a sparse vector. Column/row
 
43
sorting is not implemented for sparse matrices.
 
44
.SH EXAMPLE
 
45
.nf
 
46
[s,p]=sort(rand(1,10));
 
47
//p  is a random permutation of 1:10
 
48
A=[1,2,5;3,4,2];
 
49
[Asorted,q]=sort(A);A(q(:))-Asorted(:)
 
50
v=1:10;
 
51
sort(v)
 
52
sort(v')
 
53
sort(v,'r')  //Does nothing for row vectors
 
54
sort(v,'c')
 
55
.fi
 
56
.SH SEE ALSO
 
57
find
 
58