How to Sort Paragraphs and Text in InDesign
Did you know that InDesign has a “sort paragraphs” feature built in? No, it’s not in any of the menus. No, it’s not in the Paragraph panel or Control panel, or anyplace else that you’d likely look. Instead, it’s hiding inside the Scripts panel.
Important: The Sort Method is critical if you have applied any formatting to parts of your text — for example, if you made one of the paragraphs bold, or you have applied a hyperlink to text inside one of the paragraphs, or even if you have made a single word italic. If you use the default setting — Ignore Formatting — then the local formatting will get all messed up! It will be there, but be applied to the wrong text. Oops. So unless the text formatting is consistent throughout all the text, you want to change the Sort Method to “Retain Formatting (slower)”.
The Ignore Spaces feature lets you choose whether InDesign should pay attention to space at the beginning of the paragraph (such as tabs or space characters). You usually want this on.
Reverse Sort is pretty obvious.
You usually want to run the script after selecting the paragraphs with the Type tool. (Though you can also run it if you have a text frame selected with the Selection tool and it will sort all the paragraphs in the story.) Here’s a before and after:
There is one significant problem with this script: It doesn’t handle numbers very intelligently. For example, if your paragraphs are numbered (I mean using manual numbering, not the automatic numbering) from 1 to 30, then after sorting, the paragraphs will be numbered 1, 10, 11, 12 … 18, 19, 2, 20, 21, … and so on.
Here’s another problem: If you need to sort paragraphs a lot, it’s a hassle to find the script inside the Scripts panel each time. Fortunately, you can assign a keyboard shortcut to a script with Edit > Keyboard Shortcuts. Just look inside the Product Area called Scripts:
Sorting InDesign Tables
Here’s another problem with the script mentioned above: It doesn’t work on tables. Fortunately, Peter Kahrel wrote a great script that works with CS3 and later, which you can find here. After clicking View Script on that page, you’ll need to install it in InDesign. To learn how to do that, see this article. If you find this script useful, please click the Make a Donation button on Peter’s page! That will encourage him to keep up the amazing work he does for the community.