Thanks for coming to, the world's #1 resource for all things InDesign!

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.

sort paragraph script

Fortunately, it’s not hard to run a script. You can find the Scripts panel inside Window > Utilities. Then find the script by clicking the expand triangles, to look inside Application/Samples/Javascript. Then scroll down, and finally double-click the script you want to run. When you double-click the SortParagraph.jsx script, it asks you a few questions:

sort paragraph questions

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:

assign shortcut to script

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.

David Blatner

David Blatner

David Blatner is the co-founder of the Creative Publishing Network, InDesign Magazine, and the author or co-author of 15 books, including Real World InDesign. His InDesign videos at are among the most watched InDesign training in the world. You can find more about David at
David Blatner

Latest posts by David Blatner (see all)

  • - November 30, -0001
Related Articles

15 Comments on “How to Sort Paragraphs and Text in InDesign

  1. Yes but…

    Be aware that this script does not do its job perfectly with non-roman characters.

    If you open the script in a text editor, you will notice that there are no character tables for Greek, Cyrillic languages,…

    Check the final result of the sorting process before you definitively approve the document.

  2. It’s ridiculous that Sort isn’t a regular menu item in InDesign. How hard is it really?

    And I’d kill to have a sort function that could ignore A, An, and The in titles. You’d think in all these years of computing this would be a common thing.

  3. Adobe is piling up so much unnecessary features on every new version of InDesign. And we have a simple function as this, thats not only hidden in the scripts, but its buggy. Adobe should have their Indesign engineers read every day before they start to work.

  4. I wouldn’t say that InDesign has it built into it.

    The scripts that come with InDesign are there as examples of scripts that can be built, and used as a starting point – not really to be used out of the box, but many can.

    Unfortunately you need to know how to script to customise them. Luckily the Indesign Scripting forum is awash with people willing to help people with scripts.

    Here’s another script for sorting Tables.

    as for the thought of Adobe not having “Sort” functions native to the UI menus.

    I would argue that InDesign is a page layout tool. All the text should be sorted, and in order when it comes to you. I don’t really believe in starting a project from Scratch in InDesign.

    Although a lot of people do. I would rather use tools better associated with Database sorting to sort my Tables, paragraphs of text etc.

    For this reason I copy my text to excel – Data Sort and copy back in.

    Far faster and Excel is better suited to this task.

  5. Because auto-numbered list items will renumber as their positions change when sorted, to retain the original numbers, it’s necessary to number paragraphs manually before sorting.

    Here’s a thought about working around the default sort method that that arranges static numbers into an order like this: “1, 10, 11…” etc.

    Consider manually adding a leading zero before single-digit numbers, like 01, 02, etc. Create a GREP or nested paragraph style that applies a Paper colored character style to the leading zero that begins a paragraph, and ignore other paragraphs. This will preserve the correct numeric order, and will also align the single-digit numbers with two-digit numbers. If the numbers go into three digits, you’ll need to set tabs and tab stops with the appropriate alignment properties.

  6. Better to use a Fill of None rather than Paper.

    Can be problematic if exporting your file to RTF or other- like epub you’d end up with numbering of 001 for a list, where it should be 1.

  7. I know this if off topic but I’m looking into starting my own
    blog and was wondering what all is needed to get set up?

    I’m assuming having a blog like yours would cost a pretty penny?
    I’m not very web savvy so I’m not 100% sure. Any suggestions or advice would be greatly appreciated.

  8. Hi,

    I wish to know if there is a change to sort page numbers in the table of contents but not just first digit but a number as a whole (e.g. 346 or 45). When I use Script it only sorts the numbers by the first digit so it the end I have sorted it like : 1,10,100,2,20,200,3,30,300 etc.. How can I fix it?

  9. Hi David, I am wondering if you have anything regarding the sorting of Indexes. I am running into the problem that InDesign sorts character and my editor wants it sorted by word, so when the Index entry goes like this:

    Basic Word

    They actually want it in the sequence like this:

    Basic Word

    Do you know of any feature to handle this? I know FrameMaker has it. I wonder if InDesign does too.

    Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *