The angular momentum components in Cartesians are $$\hat L_x=\hat y\hat p_z-\hat z\hat p_y$$ $$\hat L_y=\hat z\hat p_x-\hat x\hat p_z$$ $$\hat L_z=\hat x\hat p_y-\hat y\hat p_x$$
Starting from $[\hat L_x,\hat L_y]=\hat L_x \hat L_y-\hat L_y \hat L_x$
$\begin{align}\hat L_x\hat L_y &=(\hat y\hat p_z-\hat z\hat p_y)(\hat z \hat p_x-\hat x\hat p_z)\\&=\hat y\hat p_z\hat z\hat p_x-\hat y\hat p_z\hat x\hat p_z-\hat z\hat p_y\hat z\hat p_x+\hat z\hat p_y\hat x\hat p_z\end{align}\tag{1}$
$\begin{align}\hat L_y\hat L_x&=(\hat z \hat p_x-\hat x\hat p_z)(\hat y\hat p_z-\hat z\hat p_y)\\&=\hat z\hat p_x\hat y\hat p_z-\hat z\hat p_x\hat z\hat p_y-\hat x\hat p_z\hat y\hat p_z+\hat x\hat p_z\hat z\hat p_y \end{align}\tag{2}$
Now, to find $[\hat L_x,\hat L_y]$ I need to subtract $(2)$ from $(1)$
$\begin{align}\hat L_x \hat L_y-\hat L_y \hat L_x&=\hat y\hat p_z\hat z\hat p_x-\hat y\hat p_z\hat x\hat p_z-\hat z\hat p_y\hat z\hat p_x+\hat z\hat p_y\hat x\hat p_z\tag{3}\\&-\hat z\hat p_x\hat y\hat p_z+\hat z\hat p_x\hat z\hat p_y+\hat x\hat p_z\hat y\hat p_z-\hat x\hat p_z\hat z\hat p_y\end{align}$
Now, in order to show the relation in the title of this question, I need to commute some of the $\hat r_i$, and $\hat p_j$, subject to, $$[\hat r_i,\hat p_j]=i\hbar \delta_{ij}$$ where, $\hat r_i \in \{\hat x,\hat y,\hat z\}$ and $\hat p_j \in \{\hat p_x,\hat p_y,\hat p_z\}$ But, I can only commute those which have a vanishing commutator.
The 1st and 5th terms in $(3)$ are
$\hat y\hat p_z\hat z\hat p_x$ and $-\hat z\hat p_x\hat y\hat p_z$ respectively.
I know that I can swap the order of the $\hat z$ and $\hat p_x$ in the 1st term as the commutator is zero. But I cannot commute the $\hat p_z$ and $\hat z$ as the commutator is non-zero. So the first term is $\hat y\color{red}{\hat p_z\hat p_x}\hat z$. Now, I want to get the $\hat p_z$ and $\hat z$ at the end of that term; $\hat y\hat p_x\hat p_z\hat z$
The problem is that the $\color{red}{\hat p_x}$ and $\color{red}{\hat p_z}$ do not commute.
Put simply, I need the bracketed part $\hat y\color{red}{(}\hat p_z\hat z\color{red}{)}\hat p_x$ at the end to make any progress with this derivation.
But how can I commute $\color{red}{(}\hat p_z\hat z\color{red}{)}$ past $\hat p_x$ if their commutator is non-zero (I know this as I have calculated it)?
From my notes it just says:
$$\begin{align}\hat L_x \hat L_y-\hat L_y \hat L_x&=\hat y\hat p_x\hat p_z\hat z-\hat y\hat x\hat p_z^2-\hat p_x\hat p_y\hat z^2+\hat x\hat p_y\hat z\hat p_z\\&-\hat y\hat p_x\hat z\hat p_z+\hat y\hat x\hat p_z^2+\hat p_x\hat p_y\hat z^2-\hat x\hat p_y\hat p_z\hat z\end{align}$$ $$\begin{align}[\hat L_x ,\hat L_y]&=\hat y\hat p_x[\hat p_z,\hat z]+\hat x\hat p_y[\hat z, \hat p_z]\\&=-i\hbar\hat y\hat p_x+i\hbar\hat x\hat p_y\\&=i\hbar \hat L_z\end{align}$$
Since those operators don't commute; How was the author of this able to reach the result above?
Edit:
According to the comment regarding $[\hat p_x,\hat p_z]=0$
But when calculating, $$\begin{align}[\hat p_x,\hat p_z]&=-i\hbar \frac{\partial}{\partial x}\left(-i\hbar \frac{\partial}{\partial z}\right)-\left(-i\hbar \frac{\partial}{\partial z}\left(-i\hbar \frac{\partial}{\partial x}\right)\right)\\&=-\hbar^2\frac{\partial}{\partial x}\frac{\partial}{\partial z}+\hbar^2\frac{\partial}{\partial z}\frac{\partial}{\partial x}\ne 0\end{align}$$
Unless $$\frac{\partial}{\partial x}\frac{\partial}{\partial z}=\frac{\partial}{\partial z}\frac{\partial}{\partial x}$$
So put simply, I thought that the derivative operators must be in the same order else the commutator will be non-zero.
Why doesn't it matter if the operators are not in the same order in both terms?
The trick is to rewrite $p_i x_i$ as $[p_i, x_i] + x_i p_i$.
First we expand $[L_x, L_y]$: $$ [L_x, L_y] = [y p_z - z p_y, z p_x - x p_z] = [y p_z, z p_x] - [z p_y, z p_x] - [y p_z, x p_z] + [z p_y, x p_z] $$
Then we expand each of the above commutators: $$\begin{align} [y p_z, z p_x] &= y p_z \, z p_x - z p_x \, y p_z = y ([p_z, z] + z p_z) p_x - y z p_x p_z = y (-i\hbar + z p_z) p_x - y z p_x p_z = -i\hbar y p_x \\ [z p_y, z p_x] &= z p_y \, z p_x - z p_x \, z p_y = z^2 p_x p_y - z^2 p_x p_y = 0 \\ [y p_z, x p_z] &= y p_z \, x p_z - x p_z \, y p_z = xy p_z^2 - xy p_z^2 = 0 \\ [z p_y, x p_z] &= z p_y \, x p_z - x p_z \, z p_y = xz p_y p_z - x ([p_z, z] + z p_z) p_y = xz p_y p_z - x (-i\hbar + z p_z) p_y = i\hbar x p_y \end{align}$$
Thus, $$ [L_x, L_y] = -i\hbar y p_x - 0 - 0 + i\hbar x p_y = i\hbar (x p_y - y p_x) = i\hbar L_z . $$