Refactor reporting handling as a precondition for sorting output.