I'm using the awesome Desmos Graphing calculator to graph cyclic quadrilaterals. The idea is that the user can drag a slider to change the value of the angle of each point A, B, C and D. I have done the graphing, and the quadrilateral is shaded in but there are errors. Have a look at it here: https://www.desmos.com/calculator/upedxiobuq, you will notice that when you move a point further than the one after it (ie A>B) then strange things occur,
So I came up with idea of making A not just the user input, but the lowest out of all four angles, and B would be the second highest and so on.
I thought of using the max and min functions, but I found that it is isn't actually so easy to avoid every exception. A and D are simple, just $$ min(min(a,b),min(c,d)) $$ For a, for example.
But B and C are more complicated. I have considered a big tree of maxes and mins although I am not even sure if that would work or how to do it, but I want to know if there is a more efficient way to do it.
P.S.
If the graph doesn't shade in properly, try toggling the bottom several functions by clicking the blue icon on the left. Turn all of them off and then one by one turn them on. Some will not appear as they are conditional and account for certain positions of the points.
An expression made up of a complicated structure of $\max$ and $\min$ operations is more or less equivalent to looking at one output of a sorting network. There is a 4-wire example sorting network in the article, and each node corresponds to either an input value or the $\max$ or $\min$ of two other nodes.