Fix sorting errors of symbolic expressions.

This is due to changes in symbolic expressions between Sympy 0.7.2 and
Sympy 0.7.3.