Purely out of curiousity, I was thinking about the following question:
Let $[n]$ be the set $\{0,1,2,\ldots,n-1\}$ and consider the cartesian product $[n]\times [m]$. Given any bijection $f:[n]\times[m]\rightarrow [nm]$, let's define its distortion as the greatest difference $|f(x_1)-f(x_2)|$ in its evaluation between two adjacent elements $x_1$ and $x_2$ of $[n]\times[m]$ where "adjacency" is considered that they agree in one coordinate and differ by exactly $1$ in the other coordinate. What is the minimum possible distortion of any bijection?
One might consider this as something about minimizing the Lipschitz constant of a bijection between a discrete line segment and a lattice rectangle under the taxicab metric.
One can constrain the answer fairly well: for a lower bound to distortion, observe that some element $x_1$ of $[n]\times [m]$ must have $f(x_1)=0$ and some $x_2$ must have $f(x_2)=nm-1$. There has to be some path of at most $n+m-2$ points in $[n]\times [m]$, each adjacent to the prior, connecting $x_1$ and $x_2$. Thus, some difference along this path must be at least $\frac{nm-1}{n+m-2}$.
On the other side, one can consider the explicit bijection $f(a,b)=ma+b$ or $g(a,b)=a+nb$ to get that some bijection has distortion at most $\min(n,m)$. There are other maps that attain this bound (e.g. you can adapt Cantor's pairing function to this finite domain to get this bound - essentially by ordering the points of the rectangle by diagonals and the filling each diagonal in in a consistent order). My guess is that this bound is optimal, although I lack a good argument to prove it. There's roughly a ratio of $2$ between the two bounds I give here in the worst case.
As far as exact results, this the distortion is clearly at least $1$ for any map $[1]\times [n]\rightarrow [n]$ where $n\geq 1$ and at least $2$ for any map $[2]\times [n]\rightarrow [2n]$ where $n\geq 2$ simply due to the pigeonhole principle. One can work out that all maps $[3]\times [3]\rightarrow [9]$ (and by extension $[3]\times [n]\rightarrow [3n]$ for $n\geq 3$) have distortion at least $3$ by extending the lower bound argument a touch. I checked with computer that $[4]\times [4]\rightarrow [16]$ maps have distortion at least $4$ and $[5]\times [5]\rightarrow [25]$ maps have distortion at least $5$. I told my computer to try working on the $[6]\times[6]$ case but I'm not optimistic that it will survive the combinatorial explosion.
We claim that for any natural numbers $n,m\ge 2$ any bijection $f:[n]\times[m]\rightarrow [nm]$ has distortion at least $d=\min\{n,m\}$. Indeed, let $k$ be the smallest number such that a set $S=f^{-1}([k])$ contains a number from each row or a number from each column of a rectangular set $[n]\times[m]$. It is easy to check that there are at least $d$ numbers of $[n]\times[m]\setminus S$ adjacent to a number of $S$. So $f(x)\ge k+d$ for some of these $d$ numbers. Since $x$ is adjacent to some number $y\in S$, we have $|f(x)-f(y)|\ge k+d-k=d$.