Reduce the number of pages to check for sorting

Improve algorithm for checking sort sequence
PEP8 fixes

Currently we are checking all of the pages of submissions (approx 50 of them) to verify that results are sorted correctly. This pull request reduces that to 10 pages. I am hoping that this will eliminate the timeouts we are seeing on this test.

I also improved the algorithm for checking the sort sequence as it wasn't particularly accurate.