Let $f: \mathbb{R} \rightarrow \mathbb{R}$ be a continuous, nondecreasing function. Is it true that there exists some partition of the real line $-\infty = a_0 < a_1 < \dots < a_n < a_{n+1} = \infty$ such that on each interval $[a_i, a_{i+1}]$, $f$ is either concave or convex?
Intuitively, I think the answer should be "yes", because a continuous, nondecreasing function should look like a bunch of "s" shaped curves connected with each other. However, I'm not quite sure how to formalize this.
Edit: As mentioned by @tkf, the Cantor function is a counterexample. What are some sufficient conditions on $f$ that would make this true? E.g. absolute continuity? continuous differentiability?