Let $f$ be a real function $f:\mathbb{R}\to\mathbb{R}$ Or $f:[a,b]\to\mathbb{R}$
Prove that if $f$ is surjective and non-decreasing(or non-increasing) then it's continuous
My attempt: W.L.O.G say $f$ is non-decreasing and for a point $x_0\in[a,b]$ fix an $\epsilon >0$ , then By surjectivity for $ y_1,y_2\in V_{\epsilon}(f(x_0))$ such that $y_1\in]f(x_0)-\epsilon,f(x_0)[$ and $y_2\in]f(x_0),f(x_0)+\epsilon[$ ; $\exists x_1,x_2\in[a,b]$ such that $f(x_1)=y_1\land f(x_2)=y_2$
Since $y_1<f(x_0)<y_2$ and the fact that the function is non-decreasing (contraposition of the implication of the monotonie) We get $x_1<x_0<x_2$
Now I have to find a $\delta>0$ such that for all $x\in[a,b]$ such that $|x-x_0|<\delta$ we must have $|f(x)-f(x_0)|<\epsilon$
I still have an idea to complete it, I don't know if it will help, I'm trying to complete it. I also read some proofs using the supr and inf limits or using some concepts from topological something which not something I'm already familiar with so if someone can help with this method or other simple or interesting methods?