Is there a function that maps all integers from $1$ to $m\cdot n$ in ascending order to an $m\times n$ matrix?
Is $a_{ij}=(i-1)\cdot n+j$ what you're looking for?
You can go \begin{align}&A_{\left\lfloor \frac{x-1}{n}\right\rfloor+1,\ x-n\left\lfloor\frac{x-1}n\right\rfloor}=x\\ &A_{ij}=n(i-1)+j\end{align}