This is the converse of Prove that if function f is monotonic, then it is one-to-one. Let $f \colon (a,b) \to \mathbb{R}$ be a continuous function. Prove that if $f$ is one-to-one in $(a,b)$, then $f$ is monotonic.
What I am thinking is assume by contradiction that if $f$ is not monotonic, there exists $x_1, x_2, x_3, x_4$ s.t. $x_1 \le x_2, f(x_1) \le f(x_2), x_3 \le x_4, f(x_3) \ge f(x_4)$. Try to find two points $y_1,y_2$ where $f(y_1) = f(y_2)$. However I find the there are too many cases need to be considered for example the order of $x_1,x_2,x_3, x_4$, the order of $f(x_1),f(x_2),f(x_3),f(x_4)$ and $=$ or $<$.
I think you're on the right track.
Assume there exists $a, b$ in the domain such that for some $c \in (a, b)$, $f(c) < f(a) < f(b)$ (there exists a dip downwards). By intermediate value theorem, there exists $d_1 \in (a, c)$ and $d_2 \in (c, b)$ such that $f(d_1) = f(d_2)$.
Apply the same logic to a descending $f$ and you should also reached a contradiction. $f$ isn't one-to-one.