This script sorts multiple sections of an InDesign story into alphabetical order according to the heading of each section. Version 1.1 of this script has been updated to work with InDesign CS 5.0 through InDesign CC 9.2. The script has 3 sorting options. You can sort a story by:
- Entire text of heading paragraphs
- Word after index marker within headings
- Word or phrase identified by character style within headings
The key to getting the correct result is making sure that the heading for every section is a single paragraph and has the same paragraph style applied. The paragraph style used for section headings must be used exclusively for that purpose within the story. Each section in the story will likely have a different number of paragraphs. That’s fine. The script determines what makes up a section according to the consistently applied heading paragraph style.
Target a story for sorting by placing an active cursor anywhere in that story. A sorted copy of the story will be placed in a new text frame on the first page of the active document.
Please note that this script is not for use in cases where the text to be sorted contains cross-references. Any cross-references present in the text will become invalid as a result of the sorting operation performed. Hyperlinks in the sorted text are preserved.
If you need to sort a story with many sections spanning across many pages sortStoryByHeadings might be just what you need.
The script is made available on an “AS IS” basis with no warranty of any kind, either express or implied.