Script to sort an InDesign story by its headings (InDesign CS5 through CC9.2)

sortStoryByHeadings.jsxbin

sortStoryByHeadings.jsx

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.

See a demo of the script on YouTube.

The script is made available on an “AS IS” basis with no warranty of any kind, either express or implied.

This entry was posted in ExtendScript, InDesign. Bookmark the permalink.

3 Responses to Script to sort an InDesign story by its headings (InDesign CS5 through CC9.2)

  1. Travel Tours says:

    You have some genuinely beneficial information composed here. Good job and keep posting good stuff.
    My blog is Travel Tours.

  2. Pingback: This Week in InDesign Articles, Number 81 | InDesignSecrets

  3. Pingback: harvey

Leave a Reply