Let $S=\{ (x_1,x_2,x_3,) : x_1 \le x_2 \le x_3 \}$
For a given by ${\bf y}$ how to solve the following problem \begin{align} \min_{ {\bf x} \in S} \| {\bf y}-{\bf x}\|. \end{align}
The question asks what is the closest ordered vector any other vector.
If ${\bf y} \in S$, then the minimizer is given by ${\bf x}={\bf y}$. Therefore, the interesting case occurs when ${\bf y} \in S^c$.
There is no simple formula; rather, you have to consider cases. Assuming $\mathbf{y}\notin S$, the nearest point $\mathbf{x}\in S$ will lie on the boundary of $S$. We can partition this boundary into three parts:
Here is a recipe for finding the nearest point of $S$: