Add sorting to the output