Updated sorting code. Fixed run_tests.py script. Updated some other code.
Added todo.