pep8 fix
made reorder work with python 3
simplified logic of reorder