reorder: Use the tuple of questionnaire ID and global ID for grouping.

Both the questionnaire ID and global ID need to be the same to group the
images together.