Fixed import syntax for python 2/3 compat.
Added __hash__() functions for classes w/__eq__.

In python 3.x, classes that override __eq__ but not __hash__ become
unhashable and un-sortable.
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.
Integer division must be explicit in python 3.x.