I made an action:
1. Create an oversized contact sheet (mine 11" x 16", 5 columns x 6 rows to end up on A4)
2. Turn rulers on if they aren’t.
3. Create a new action (I called mine Compact contact) and record the following steps:
4. Draw a marquee round the right-most column, with enough clearance for portrait orientation at the top and bottom and for landscape at the sides. Do a new layer via cut. Reselect the thumbnail layer.
5., 6., 7. Repeat step 4. for the middle columns. You should now have five layers, including the original thumbnail layer, with one column on each.
8. Select the rightmost columns layer and, using the ruler as a guide, move it horizontally so that it is within the boundary of your desired page (in this case, so that the right edge of landscape images are no more than 7.7" from the left edge of the page).
9. Select the layers for the middle columns and move them horizontally to lie between the other two columns.
10. Link all five layers.
11. Layer>Distribute linked>Horizontal centres.
12. Merge linked layers.
13., 14., 15., 16., 17. Create layers for each row, starting from the bottom, and making sure that your selections will include portrait and landscape images.
18., 19. Move the bottom row’s layer up so that it will fit on the page (in my case base no more than 10.5" down) and push the middle four rows above it.
20., 21., 22. Link all six layers, distribute vertical centres, merge.
23. Crop down to final size.
24. Stop recording
I added a "Stop" to the action at the beginning with a reminder of my Contact Sheet settings.
This action will compress a contact sheet that does not contain any empty rows or columns. If you end up with blanks (blank rows usually, unless you reverse the order in which PS fills them) put a little squiggle on the thumbnail layer where the first thumb of each blank row should be before running the action, and erase it afterwards. The vertical spacing of the final sheet will be a bit off, but it will work.