function allCellsDistOrder(rows: number, cols: number, rCenter: number, cCenter: number): number[][] {
const pos = []
for(let row = 0; row < rows; row++) {
for(let col = 0; col < cols; col++) {
pos.push([row, col])
}
}
const sortedPos = pos.toSorted(([ar, ac], [br, bc]) => {
const aDist = Math.abs(ar - rCenter) + Math.abs(ac - cCenter)
const bDist = Math.abs(br - rCenter) + Math.abs(bc - cCenter)
return aDist - bDist
})
return sortedPos
};