order-isomorphism can send chain to other chain exercise 7.20 in Goldrei:

Let $a_1<\cdots<a_n,c_1<\cdots<c_n$ be rationals. Show that there is an order-isomorphism $f:\mathbb{Q} \to \mathbb{Q}$ such that $\forall i: f(a_i)=c_i$.

for $n=1$ we can take a translation, for $n=2$ we may take a linear polynomial $c_1+\frac{x-a_1}{a_2-a_1}(c_2-c_1)$. but for $n>2$ we cannot find a linear polynomial.
The theorem is intuitively clear, since we can stretch the interval $[a_1,a_n]$ appropriately. How can it be justified formally?
 A: OUTLINE:
The simplest way to prove this would be by induction on $n$.
For $n=1$ this is obvious, $f(x)=x+(c_1-a_1)$ is an automorphism of $\Bbb Q$ mapping $a_1$ to $c_1$.
Now suppose this is true for $n$, and take $(n+1)$-tuples $a_i,c_i$. Then there is an automorphism of $\Bbb Q$ mapping $a_i$ to $c_i$ for $i\leq n$, call it $F$. Now find a way to "cut and paste" isomorphism on the domain after $a_n$, and define $f$ as wanted.
A: The simplest way, given what you've said, is just to use a piecewise linear function.
Maybe it's worth knowing that any two linearly ordered sets are order-isomrophic that satisfy the following:


*

*They are densely ordered, i.e. between any two elements there is another; and

*They are unbounded, i.e. no max or min; and

*They are countable.


Thus, for example, there is an order isomorphism between the rational numbers and the real algebraic numbers.  Or the binary rationals (i.e. rationals whose denominator is a power of $2$). Google the term "Cantor's back-and-forth method" and you'll find a proof.
