Statistics
OrderByRank
order data items according to their ranks
Calling Sequence
Parameters
Description
Options
Notes
Examples
OrderByRank(X, R, options)
X
-
data sample
R
ranks
options
(optional) equation(s) of the form option=value where option is one of order or unique; specify options for the OrderByRank function
The OrderByRank command orders the elements/rows of X according to their ranks.
The first parameter X is the data set - given as e.g. a Vector.
The second parameter R is the ranks data (also specified as a data set).
The options argument can contain one or more of the options shown below.
order = ascending or descending -- Indicate whether the elements of X should be sorted in the ascending or descending order. The default value is order=ascending.
unique=truefalse -- If this option is set to true, all multiple occurrences of elements from X will be removed. The default value is unique=false.
The OrderByRank command creates a copy of the original Array.
with⁡Statistics:
A≔Array⁡a,b,c,d,e,f,g,h
A≔abcdefgh
B≔Array⁡5,4,3,7,6,2,8,1
B≔54376281
OrderByRank⁡A,B
hfcbaedg
Sort two arrays simultaneously.
A≔Array⁡5.,4.,3.,7.,6.,2.,8.,1.
A≔5.4.3.7.6.2.8.1.
B≔Array⁡a,b,c,d,e,f,g,h
B≔abcdefgh
C≔Rank⁡A
C≔54376281
OrderByRank⁡A,C
1.2.3.4.5.6.7.8.
OrderByRank⁡B,C
X≔Array⁡a,b,c,d
X≔abcd
Y≔Array⁡2,3,4,1
Y≔2341
OrderByRank⁡X,Y
dabc
Z≔Array⁡2,3,4,3
Z≔2343
OrderByRank⁡X,Z
Error, (in Statistics:-OrderByRank) duplicate rank: 3
OrderByRank⁡X,Z,unique=true
adc
A≔Array⁡1..6,1..2,10,a,5,b,−2,c,3,d,7,e,20,f
A≔10a5b−2c3d7e20f
R≔Rank⁡A1..−1,1
R≔531246
OrderByRank⁡A,R
−2c3d5b7e10a20f
See Also
Statistics[Computation]
Statistics[Rank]
Statistics[Sort]
Download Help Document