Which integration is right? (Integration of operators and delta functions) Let us consider following integral
$$\int \int dx dy f(x)g(y)\delta(x-y).\tag{1}$$
We can bring integral with respect to $x$ to the front or $y$ to the front and integrate out to get the same answer
$$\int dx f(x) \int dy g(y) \delta(x-y) = \int dx f(x) g(x),$$
$$\int dy g(y) \int dx f(x) \delta(x-y) = \int dyg(y)f(y).$$
However, it seems different for operators. Consider
$$\int \int dx dy \hat{A_x}\hat{B_y}\delta(x-y)\psi(x,y).\tag{2}$$
and integrate in two ways
$$\int dx \hat{A_x} \int dy \hat{B_y} \delta(x-y)\psi(x,y) = \int dx \hat{A_x} \hat{B_x}\psi(x,x),$$
$$\int dy \hat{B_y} \int dx \hat{A_x} \delta(x-y)\psi(x,y) = \int dy\hat{B_y}\hat{A_y}\psi(y,y) ,$$
where $\psi(x,y)$ is a function, and this differs by $[\hat{A},\hat{B}]$.
I suspect that
$$[\hat{A_x}, \delta(x-y)] \neq 0,$$
but I can't utilize this insight to get a consistent conclusion. Can someone shed some light on this?
 A: *

*Here we assume $A_x$ and $B_y$ are differential operators in the $x$ and $y$ variables, respectively. They commute since they depend on different variables. 

*OP's previous expression (v3)
$$\iint_{\mathbb{R}^2}\! dx~dy~ \hat{A}_x\hat{B}_y\delta(x-y)\tag{i}$$ 
is not mathematically well-defined: A distribution (such as the Dirac delta distribution) should have a way to act on test functions. 

*In later versions OP includes a test function: 
$$\begin{align}\iint_{\mathbb{R}^2}\! dx~dy~\psi(x,y)~ \hat{A}_x\hat{B}_y\delta(x-y)
~=~&\iint_{\mathbb{R}^2}\! dx~dy~\delta(x-y)~\hat{A}^T_x\hat{B}^T_y\psi(x,y) \cr
~=~&\int_{\mathbb{R}}\! dz~\hat{A}^T_1\hat{B}^T_2\psi(z,z)  ,\end{align}\tag{ii}$$ 
where the superscript "$T$" denotes the transposed differential operator, and the subscripts "$1$" and "$2$" indicate which entries of the test function $\psi$ that the differential operator acts on. In the first equality of eq. (ii) we integrated by parts. We repeat (to rule out any possible misunderstanding) that at any step the two differential operators commute.
