Block-sorting rows and columns in a 2D array
R, 55 bytes



function(x,n)`if`(n&gt;0,x[,+x[n,]],x[+x[,-n],])
`+`=order


Try it online!

Reassigns the + operator (actually a function in R) to the order function, which returns the indices of a vector from smallest to largest. Then it's just array manipulation.