Programmer Guide/Command Reference/EVAL/sort: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
No edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
=====sort=====
Sort the vector or matrix ''x''.
 
;Usage: <code>'''sort(''mode'', ''x'' {, ''i'' })
Sort the the rows or the columns of the vector <var>x</var>. This is a subcommand of the <code>[[Programmer Guide/Command Reference/EVAL/EVAL|EVAL]]</code> command.
;''mode'': specifies the sort direction and selects if ''x'' is sorted by the values of a row or column
 
;''x'': vector or matrix to be sorted; must be a matrix if ''mode''>1
{|
;''i'': row or column containing the sort data; depends on ''mode'' (default=0)
|-
;Result: The sorted vector or matrix ''x''.
|Usage:
:{|class=einrahmen
|sort( dir{0|1}, <var>x</var>, [<var>col</var>=0])
!''mode'' !! ''i'' !! description
|-
|
|sort( dir{2|3}, <var>x</var>, [<var>row</var>=0])
|-
|Parameters:
|{|
|-
|-
|<var>dir</var>
|'''0'''|| column index || sort rows of ''x'' ascending by the values of column ''i''
|The direction to sort in (0=sort the rows in ascending order, 1=sort the rows in descending order, 2=sort the columns in ascending order, 3=sort the columns in descending order).
|-
|-
|x
|'''1'''|| column index || sort rows of ''x'' descending by the values of column ''i''
|The vector to sort.
|-
|-
|col
|'''2'''|| row index || sort columns of ''x'' ascending by the values of row ''i''
|The column to use for sorting.
|-
|-
|row
|'''3'''|| row index || sort columns of ''x'' descending by the values of row ''i''
|The row to use for sorting.
|}
|}
;See also: [[../median|median]], [[../sample|sample]], [[../shuffle|shuffle]]


 
[[../#Functions|<function list>]]
|  
|-
|Return Type:
|no result
|}

Latest revision as of 11:57, 21 April 2011

Sort the vector or matrix x.

Usage
sort(mode, x {, i })
mode
specifies the sort direction and selects if x is sorted by the values of a row or column
x
vector or matrix to be sorted; must be a matrix if mode>1
i
row or column containing the sort data; depends on mode (default=0)
Result
The sorted vector or matrix x.
mode i description
0 column index sort rows of x ascending by the values of column i
1 column index sort rows of x descending by the values of column i
2 row index sort columns of x ascending by the values of row i
3 row index sort columns of x descending by the values of row i
See also
median, sample, shuffle

<function list>

Navigation menu

Personal tools