This question was inspired by this:
Finding a non-piece wise function that gives us the $i$'th largest number.
My question is how to do this for four or more values.
In other words, given 4 values $a, b, c,$ and $d$, specify functions $order_i(a, b, c, d)$ for $i = 1 $ to $4$ such that $order_i(a, b, c, d)$ returns the $i^{th}$ smallest value.
Here is my start as an answer for 4 values:
Define a set of auxiliary functions
$bmin2(a, b) =\frac12(a+b-|a-b|) $, $bmax2(a, b) =\frac12(a+b+|a-b|) $, $bmin3(a, b, c) =bmin2(bmin2(a, b), c) $, $bmax3(a, b, c) =bmax2(bmax2(a, b), c) $, $bmin4(a, b, c, d) =bmin2(bmin3(a, b, c), d) $, $bmax4(a, b, c, d) =bmax2(bmax3(a, b, c), d) $, $bcenter(a, b, c, d) =a+b+c+d-bmax4(a, b, c, d)-bmin4(a, b, c, d) $.
We get the min and max, and we can get the sum of the middle two, but how to separate that sum into the individual values so we can we can decide which is smaller is not immediately clear to me.
As to doing this for 5, oy!
And, for general $n$, I have no idea.