Issue #7792 made `x < I` different from `I < x`: fix and add tests

I noticed that #7792 makes `I < x` raise an error.  But `x < I` is unevaluated.  Here's an attempt to fix.

Also, add tests.
Please advise if other.is_real is dangerous?

I worried other might be float, int or whatever, but couldn't make that actually occur...