What is the mathematical definition of a function that gives the rank order of the components of a vector?

44 Views Asked by At

Mathematically, how can a function $f()$ be defined such that it takes an N-dimensional vector $\vec v$ and gives the rank ordering $\vec r$ of the components of $\vec v$? The components of $\vec r$ are some permutation of $[0, 1, 2 ... N-1]$ for an N-dimensional vector.

$$ f(\vec v) = \vec r \\ f([1,2,3]) = [0,1,2] \\ f([6,-2,4]) = [2,0,1] $$

If the component values $v_a$ and $v_b$ of $\vec v$ are have the same value, the lower rank order $R$ is assigned to the lower index $r_a$ of $\vec r$, and $r_b=R+1$ where $a<b$.

$$ f([0,0,0]) = [0,1,2] \\ f([1,-1,-1,1]) = [2,0,1,3] \\ f([0,0,-1,0,1]) = [1,2,0,3,4] $$

I am also interested in the mathematical definition of a function $g()$ that gives the rank ordering of the absolute value of the components of $\vec v$.

$$ g([1,-1,-1,1]) = [0,1,2,3] \\ g([0,0,-1,0,1]) = [0,1,3,2,4] $$