replace respects commutativity

Reported by Keaton Burns in https://groups.google.com/forum/#!topic/sympy/8wCgeC95tz0