\(\left(x-y\right)^2+4\left(y-x\right)-5=\left(x-y\right)^2-4\left(x-y\right)+4-9=\left(x-y-2\right)^2-3^2=\left(x-y-2-3\right)\left(x-y-2+3\right)=\left(x-y-5\right)\left(x-y+1\right)\)
\(\left(x-y\right)^2+4\left(y-x\right)-5\)
\(=\left(x-y\right)^2-4\left(x-y\right)-5\)
\(=\left(x-y-5\right)\left(x-y+1\right)\)