TITLE: Rearrange all the real numbers between $0$ and $1$
QUESTION [14 upvotes]: Can we rearrange all the real numbers between $0$ and $1$, denote
 $f(x):(0,1) \rightarrow (0,1)$ (a bijection), such that for $$\forall 0<x_1<x_2<\dots<x_n<1,$$ neither $$f(x_1) <f(x_2) <\dots <f(x_n)$$ nor $$f(x_1)>f(x_2)>\dots>f(x_n)$$ can be hold $(n>3)$?
I'd like to see an answer in particular for $n=4$ and $n=5$.

REPLY [7 votes]: No need to bring in Ramsey theory!
Given such a function $f$, consider the sequence
$$
f\left(1 - \tfrac{1}{2} \right),\;
f\left(1 - \tfrac{1}{3} \right),\;
f\left(1 - \tfrac{1}{4} \right), \ldots
$$
As any sequence in $\mathbb{R}$ has a monotone subsequence, there exists an increasing sequence of real numbers $x_i$, $0 < x_1 < x_2 < x_3 < \cdots$, such that
$$
f(x_1) \le f(x_2) \le f(x_3) \le \cdots
\text{ or }
f(x_1) \ge f(x_2) \ge f(x_3) \ge \cdots
$$
and since $f$ is a bijection, equality cannot hold, i.e.
$$
f(x_1) < f(x_2) < f(x_3) < \cdots
\text{ or }
f(x_1) > f(x_2) > f(x_3) > \cdots
$$
so the rearrangement you ask for is impossible for any $n$.