Let $f: [-\infty, \infty] \to [-\infty, \infty]$.
What conditions should we impose on $f$ so that the following statement becomes true?
$$\forall \ X \subset [-\infty, \infty], \sup f(X) = f(\sup X)$$
If that doesn't make much sense, then for some function with certain conditions, what kind of sets $X$ satisfy $f(\sup X) = \sup f(X)$?
Some background to the question:
While doing a certain proof, I was about to swap $\sqrt{\cdot}$ and $\sup$, but I soon realized that such a step probably needs some scrutiny. I still do not know whether such a step is valid, and I would like to know what sort of functions satisfy the requirement. I supposed that $f$ is an extended real valued function for the possibility of $\sup = \infty$.
I believe the sufficient and necessary condition for $f$ is that it is nondecreasing, left-continuous (i.e. for all $x_0$, $\lim\limits_{x\rightarrow x_0^-}f(x)=f(x_0)$) and $f(-\infty)=-\infty$. Last condition is necessary for consideration of $X=\varnothing$. First condition is necessary as for $X=\{a,b\},a\leq b$ we need $\max\{f(a),f(b)\}=\sup f(X)=f(\sup X)=f(b)$, i.e. $f(a)\geq f(b)$. Second condition is necessary for when we take $X=(-\infty,x_0)$. Since we know $f$ is nondecreasing, $\sup f(X)=\lim\limits_{x\rightarrow x_0^-}f(x)$, and it must be equal $f(\sup X)=f(x_0)$.
As for sufficiency, assume the above three conditions. For $X=\varnothing$ of $X=\{-\infty\}$ this is clear so assume $\sup X:=x_0>-\infty$. It's easy to see that left continuity implies $\sup f((-\infty,x_0))=f(x_0)$ (thanks to monotonicity of the function), so we only need to prove $\sup f((-\infty,x_0))=\sup f(X)$. If $x_0\in X$, this is obvious from monotonicity. Clearly $\sup f((-\infty,x_0))\geq\sup f(X)$, since the former $\sup$ is taken on a (possibly) larger set. Now, take any $a\in (-\infty,x_0)$. Then there exists a $b\in X$ such that $a<b<x_0$ (since $a$ is smaller than $\sup X$). Now $f(b)\geq f(a)$. It follows from this that every element of $f((-\infty,x_0))$ is not larger than some element $f(X)$. Hence $\sup f((-\infty,x_0))\leq\sup f(X)$, so $\sup f((-\infty,x_0))=\sup f(X)$, as we wanted.