Print as PDF - Sort the Output Alphabetical by Last Name

I have Print as PDF setup for Contacts. All works fine, I can filter and select a group to print and it generates a PDF with one page for each contact. I need the PDF to print out in Alphabetical order by the contact’s last name. The current order seems random, I can’t figure out how it is sorted.
Any ideas?

You might be better off working from Reports module.

You can still use the list view filter, if you need it. Just do it two steps.

  1. From the list view, add to a target list.
  2. From the Report, iterate that target list’s contacts and build your report as you prefer.

Thanks. Did a quick look at the reports. My Print to PDF report is a single contact info on a page, about 20 fields. Looks like Reports gives me the list in standard columns and rows.

Looks like the sort order is the Contact ID. I exported my filtered list and the exported list in excel is the same order as the PDF. I sorted and resorted the excel several times and sorting the ID column brings it back to the original order. Anyone know what program or code to look at to try and modify the sort order? Thanks

I exported a filter of contacts to excel and played around with sort. It looks like the Print as PDF prints in order. So it may require modifing the code in the print program to change the print order. Does anyone know the program used for Print as PDF?

Have a look here

First, do some testing to make sure that is the file being used in the code flow that interests you. I think it is, but I am not sure.

Then you can play around with the query generation, so that it includes an ORDER BY clause.

Alternatively (less efficient, but still ok) you can leave the query as it is and sort the PHP array with the results of the query.