Fixed sorting of variables in python 3.x.

Python 2 would sort by __id__ when the class did not provide a
comparison function, Python 3 makes this explicit.