HINTS: Let $f:X\to X$ be a function. You have to prove three things:
- If $f$ is continuous, then $f$ is non-decreasing.
- If $f$ is continuous, then $f$ is continuous on the right.
- If $f$ is non-decreasing and continuous on the right, then $f$ is continuous.
(2) is trivial, so it really comes down to proving (1) and (3).
(1) is the sort of statement that almost begs to be proved either by contradiction or by proving the contrapositive, so suppose that $f$ is not non-decreasing. Then there are $x,y\in\Bbb R$ such that $x and $f(x)>f(y)$, and we’d like to use $x$ and $y$ somehow to show that $f$ is not continuous. Let $u\in\big(f(y),f(x)\big)$, and let $U=(\leftarrow,u)$. $U$ is an open nbhd of $f(y)$; is $f^{-1}[U]$ open?
For (3) a direct proof looks feasible, so suppose that $f$ is non-decreasing and continuous on the right. Let $U$ be any open subset of $X$; we need to show that $f^{-1}[U]$ is open. This is trivial if $U=\varnothing$ or $U=\Bbb R$, so we might as well assume that $U=(\leftarrow,u)$ for some $u\in\Bbb R$.
- Show that if $f(x)\in U$, then $(\leftarrow,x]\subseteq f^{-1}[U]$; this uses the fact that $f$ is non-decreasing.
- Conclude that either $f^{-1}[U]=X$, or $f^{-1}[U]$ is bounded above. In the latter case let $v=\sup f^{-1}[U]$. Clearly $f^{-1}[U]$ must then be equal either to the open ray $(\leftarrow,v)$ or to the closed ray $(\leftarrow,v]$. Use the right-continuity of $f$ to show that $f^{-1}[U]=(\leftarrow,v)$.