Julian, Thanks for pushing this forward and making the code merge-friendly.
Frankly speaking, we should consider splitting the files which would make sorting obsolete. So I would not invest in sorting much. The current code with modCount looks non-trivial, and I have no idea if there are bugs (e.g. missing modCount++) there. I am OK to trust you that it does sort the items, and I think modCount++ and the other complexity could be removed as we split the files. Here's the issue for splitting the files: https://issues.apache.org/jira/browse/CALCITE-4595 Just in case, splitting big files into per-test ones opens a way for https://approvaltests.com/ which has plugins for IDEs to operate with reference test outputs. Vladimir
