# [Python 2], 215 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]
     if M==m:break
     m=M
    print M

[Try it online!][TIO-jsbi6d86]

[Python 2]: https://docs.python.org/2/
[TIO-jsbi6d86]: https://tio.run/##VU/LbsIwELz7K1ZIlWzYqsTlDT61PUb9AMsSoTKNE2JQREny9antJAIkaz07szP2Xpprera8/fj@/BKj0agthLGXvytlJBUnbWnBtlUH5FQxUqXmpCHaEIiFviUnui/2jMDxXEIOxkKZ2F9N03HFNgYzkb9VmL9U2xseMBGFsVTSWNZKNgobrJn31dg4J3XjDKmZULNLXyPWdZhNaLarXM8U28bSKJkpjGWi5EGJ/saeJ2CO7lui2BxKneQEChGTS2nsFeLW7UaIrvUP@FXHs1bKGQJHiBSCfEdwZ@7hsmcVkZ6O@onoCa4Q1mFiHozOsEBYBuzUaR/JQ7cOZxXEB4V3KaE65yLEdQ4emNUQEEx8MPHhxUGJBs7tMw/V6165hz8oC688Evyepv4B "Python 2 – Try It Online"