Backport 3324

This backports the fix for having boolean comparisons respect array priority. ([original PR](https://github.com/numpy/numpy/pull/3324)). 

I need this in 1.7.x for adding boolean comparisons to sparse matrices in SciPy. [PR 1](https://github.com/scipy/scipy/pull/2586) [PR 2](https://github.com/scipy/scipy/pull/2561). Otherwise, comparing a sparse matrix with a dense matrix fails when the dense matrix is on the LHS.