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

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]$$

• What do you mean by "mathematical definition"? As far as mathematics is concerned, what you have just written is a fine definition (though it is possible to make it a bit more precise). – Eric Wofsey Aug 29 '16 at 6:46
• If possible, I am looking for something formulaic as opposed to a verbal description. Ultimately I want to calculate the derivative of a function that uses $f()$. – Brendan A R Sechter Aug 29 '16 at 6:52
• Also, I have a feeling I may have described something that already has a name and a standard definition. If that is the case, I would like to know what the standard name is. – Brendan A R Sechter Aug 29 '16 at 7:01
• Any such formula would be extremely difficult to use for differentiation purposes, except on the connected regions where the order is fixed, where the derivative is obvious anyway -- so much so that the question seems moot. – Did Aug 29 '16 at 7:41
• You could define it easily recursively. But it is kind of over the top and might obscure the idea. Also, you need to specify what to with duplicates, as otherwise it is ambiguous and not a function. Much hassle for nothing. – user251257 Aug 29 '16 at 13:21