# [Python 2], <s>215</s> 208 bytes

<!-- language-all: lang-python -->

    m=input()
    h=len(m);w=len(m[0])
    while 1:
     M=eval(`m`)
     for k in range(h*w):i,j=k/w,k%w;v,b,a=min([(M[x][y],y,x)for x,y in(i,j),(i+(i<h-1),j),(i,j+(j<w-1))]);M[i][j],M[a][b]=M[a][b],M[i][j]
     M!=m or exit(M);m=M

[Try it online!][TIO-jsbtirm7]

[Python 2]: https://docs.python.org/2/
[TIO-jsbtirm7]: https://tio.run/##LU7RasMwDHzPV2gPA2lV2dJtDJr6E/wFQtAUvNlJ7JaS1snXZy4NHOjuuDt0mUd/TrtliSaky21EqrwZXMJITX4S@VCqsg@Dg3pfgTXu3g54jEeq4Pd8hR5Cgmub/hz6t0z7wJ3p3zP3r7m584lbE0NCQSuTyqw880SP3sRzaWKJE2PYYDj4bU1Pxd0Gu0MumpQaK0GlU7bSqpzUrJdXv/z0YiKUSTeFES010dhlEfli2DHUyiCfDAXfD/qzuvoP "Python 2 – Try It Online"

<sub>-7 bytes, thanks to ovs</sub>