rank

Position in the sorted list

Syntax: rank x, rank[x]

Where x is a list or dictionary, returns for each item in x the index of where it would occur in the sorted list or dictionary.

This is the same as calling iasc twice on the list.

q)rank 2 7 3 2 5
0 4 2 1 3
q)iasc 2 7 3 2 5
0 3 2 4 1
q)iasc iasc 2 7 3 2 5            / same as rank
0 4 2 1 3
q)asc[2 7 3 2 5] rank 2 7 3 2 5  / identity
2 7 3 2 5
q)iasc idesc 2 7 3 2 5           / descending rank
3 0 2 4 1

iasc
Basics: Sorting