Fix constants sorting for Python 3.