2 deleted 112 characters in body

Python 2, 215215 208 bytes

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]
if M==m:break
M!=m m=M
printor exit(M);m=M


-7 bytes, thanks to ovs

Python 2, 215 bytes

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]
if M==m:break
m=M
print M


Try it online!

Python 2, 215 208 bytes

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!

-7 bytes, thanks to ovs

1

Python 2, 215 bytes

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]
if M==m:break
m=M
print M


Try it online!