OL Learn

Metadata - Group and Sorting

I have a PDF that I would like to group by a certain location (address block) using Metadata and then sort the PDF depending on how many pages would be in the group.

Example:
Location 1
Location 2
Location 3
Location 4
Location 5
Location 2
Location 2
Location 2
Location 5
Location 5

Example:
Location 1
Location 3
Location 4
Location 5
Location 5
Location 5
Location 2
Location 2
Location 2
Location 2

The workflow is set up with the follow steps and it is working to group by a certain location but I am struggling with the steps to then sort the group by how many pages would be in that group.

Workflow steps:
Create Metadata
Metadata Fields Management - Add location field
Metadata Sorter - by location field
Metadata Level Creation - Group beings with location value change
Metadata Sequencer - Group after 1 Instance
Output PDF to folder

Note: This is working if we use the DataMapper, set our records up, create a field to get the record page count and then add a metadata sorter on that field in workflow prior to sending to the template. The issue with this is that is takes a long time.