sort the tuples in the document query exactly the same way as in the subgraph query