Description:
Get the ranking of a certain member in the computed sequence.
Syntax :
A.rank(y,x) |
Equivalent to A.(x).rank(y) |
Note:
The function computes expression x over each member of sequence A and returns the ranking of a given value y in sequence A.(x). By default the sequence members are sorted in ascending order.
Options:
@z |
Return a ranking according to members sorted in descending order. Here “z” is in lowercase. |
@i |
Deduplicate sequence A.(x) before getting y’s ranking. |
@s |
Perform average operation for each of the duplicate ranking and return the result, which could contain non-integers. Take the sequence [3,2,6,6,9] for example, a default ranking is [2,1,3,3,5]; but with @s option, the ranking becomes [2.0,1.0,(3+4)/2,(3+4)/2,5.0] after we get averages for the two duplicates. |
Parameters:
x |
An expression according to which sequence A is computed. |
y |
A member of sequence A or a value for comparing members of sequence A.(x). |
A |
A sequence. |
Return value:
The ranking of a given member
Example:
|
A |
|
1 |
=demo.query("select * from SCORES where SUBJECT='English'") |
|
2 |
=A1.rank(90,SCORE) |
23; a ranking according to ascendingly ordered members |
3 |
=A1.rank@z(90,SCORE) |
5; a ranking according to descendingly ordered members |
4 |
=A1.rank@i(90,SCORE) |
10; the ranking with duplicate(s) removed |
5 |
=A1.(SCORE).rank(90) |
23 |
6 |
=A1.rank@s(90,SCORE) |
23.5; get averages for duplicate rankings and then return the final result |
Related functions: