For this question, we can assume that $f:\mathbb{R}\rightarrow\mathbb{R}$. However, I hope that an answer can generalize to arbitrary linearly ordered sets.
I assume that everyone will know what I mean by $f$ being weakly increasing, weakly decreasing, or monotonic. However, now let me introduce a different notion:
Let me say that for three real numbers $x$, $y$, and $z$ that $y$ lies between $x$ and $z$ if either of the compound inequalities below hold $$x\leq y\leq z\quad\text{or}\quad z\leq y\leq x\,.$$
Let me say also that $f$ preserves betweenness if whenever $y$ lies between $x$ and $z$ then $f(y)$ lies between $f(x)$ and $f(z)$.
Of course, a monotonic function preserves betweenness.
But the question is:
If a function preserves betweenness is it necessary monotonic? I.e., must it either be weakly increasing or weakly decreasing?
It seems like it should be, but then I recall Darboux functions and become hesitant to jump to this conclusion. If a betweenness-preserving non-monotonic function exists, it would be kind of odd.
It's readily apparent that it cannot have any strict local extrema. Also, if it has a local extremum at $x$, then there will be $a$ and $b$ such that $a<x<b$ where $f$ is constant on either $(a,x]$ or $[x,b)$ or both. However, any other properties that we investigate seem to require an intractable number of case analyses.
I'm reminded of some ghastly functions like those that satisfy the Cauchy functional equation but are not continuous anywhere. But those functions are unbounded on every interval.
Yes, betweenness-preserving implies monotonic.
Suppose $f$ is not monotonic, then there exist $a<b$, $f(a)<f(b)$, and also $c<d$, $f(c)>f(d)$. We note that $f$ is still not monotonic on $F:=\{a,b,c,d\}\subset\mathbb R$. Let's write $F$ as $F=\{a_1<a_2<\dots<a_k\}$ where clearly $k\in\{3, 4\}$.
Choose $i$ minimal such that $f(a_i)\ne f(a_{i+1})$.
Case 1: $f(a_i)<f(a_{i+1})$. Then there must be $j\ge i+1$ with $f(a_j)>f(a_{j+1})$, or else $f$ is weakly increasing on $F$. Then for the minimal such $j$ we are done: $f(a_i)<f(a_j)>f(a_{j+1})$ and $f(a_j)$ is not between $f(a_i)$ and $f(a_{j+1})$, so $f$ is not betweenness-preserving.
Case 2 is the same.