Fan of creative technology, elearning, instructional design and a little geeky

InDesign: Sorting with scripts

Updated 23-Feb-2010 Added video

You’ve spend a few days working on some great layouts for a customer. Lots of bulleted lists and tables, and when you receive the first proof back, many of the lists and tables have a note on them: “can you please sort this in alphabetical order”?

I won’t ask you what your first thought is when you read this scenario. But my response to my customer would be: “Not a problem, I’ll have an amended proof for you this afternoon, that will have things sorted as requested”. So two separate tasks to perform… and I’ll break them into two separate posts. This being the first.

Sorting Paragraphs

Let’s start with the sorting of paragraphs in alphabetical order.

I’m revealing secret number one… we won’t be going through cut-paste steps here… I just don’t have the time to show you how to reorder a long list alphabetically like that.  Instead I’d like to introduce you to one of the sample scripts that is supplied with Adobe InDesign. It is designed to sort paragraphs in alphabetical order.  What’s a script you might ask? Well it’s like a little bit of code that has been written to perform a particular task automatic, that you might otherwise need to perform manually.

Sample scripts come installed with InDesign CS3 and higher. For earlier versions of InDesign the set of sample scripts can be downloaded from the Adobe web-ste:

So where do we find these magical scripts? They come pre-installed with an InDesign installation. You access them from the Automation > Scripts panel.

094_01_ScriptsPanel

The default install in InDesign will provide a series of Sample Scripts. On the Mac in AppleScript and JavaScript format, on Windows OS the AppleScript is replaced by VB Script. AppleScript as the name says, is specific to the Mac OS. VB Script support in InDesign specific to Windows OS.

To stick with common ground between the OSes, let’s expand the JavaScript folder in the Scripts panel and see what that brings us in available Scripts.

094_01_JavaScripts

Plenty of Scripts there as you can see. I posted a summary of what each of these does quite some time ago.

Time to start sorting those paragraphs. Start by highlighting the paragraphs that need to be sorted (Type tool).

How to use a script in InDesign

There are a number of methods you can use to execute the script: Double clicking the script name in the list, or selecting the script then choosing Run Script from the Script panel menu. You can even assign a keyboard shortcut to a script if you want.

I’m using the Run Script command from the Script panel menu.

094_04_RunScript

As soon as the script is executed you’ll be prompted with an additional dialog, asking for some input on your end.

094_05_SortOptions

The Sort Options dialog appears.

First input requested from us as a user of the script is whether or not the Sort Method choose needs to Retain the formatting of the highlighted text.  If you hadn’t yet formatted your text, I would always stick to the default Ignore Formatting option, it’s nice and fast. However if you have formatted your text, then use Retain Formatting. Yep, I know it says “slower”. but believe me … slower is still fast! Depending on how much text you have highlighted… it might still all be sorted in a blink of an eye!

Yes, you can get away with retaining formatting when using the default ignore formatting settings, however, I won’t guarantee that will always work! For instance when you have a paragraph style applied to your text and also have some style overrides applied to the start of a paragraph, you’ll see some interesting (if that’s what you call them) results.

Ignore Spaces, when selected basically ignores any leading spaces found at the start of a paragraph, and sorts on the first non-space character found in that paragraph. So if you want your spaces to sort at the top of the sort order, deselect this option.

Reverse Sort, will sort in descending (Z-A) order instead of ascending (A-Z) order.

With your settings all sorted, click OK (and don’t blink an eye!! or you’ll miss it!).

094_06_AllSorted

All done! Now aren’t you glad you told your customer you’d have it done quickly. They’ll love you for it for sure!

This write-up is continued in a second blog-post.

Video Tutorial

 

Similar posts
  • Adobe InDesign and XML: A Reference Guide The following is a reference guide I have compiled over time for those of you who are looking at doing a little more with XML in InDesign (originally published Feb. 2011, last updated Feb 2018). If you have any extra information you’d like to see added to this guide, feel free to message me. Mapping XML tags to InDesign [...]
  • How to change the colour of bullet points in InDesig... A few weeks ago I recorded a short quick tip tutorial. InDesign’s Control panel, gives users a quick and easy way to format text as a bulleted list. Highlight the text, and click the Bulleted List button in the Paragraph Formatting Controls mode for the Control panel. This applies a universal bullet character as the [...]
  • Creating a pop-up window in a PDF with Adobe InDesig... In the following YouTube tutorial, we’ll create an interactive PDF from Adobe InDesign, in which we click on a button, which in turn opens up a simple pop-up window containing a close-box. When the close-box is clicked the pop-up window disappears [...]
  • InDesign: Facing pages with odd-numbered left pages Back in 2004 I wrote a tip for InDesign CS on how you could have the first page of your document be a left page AND have it start with page number 1. It’s hard to believe this is almost a decade ago… But a recent question on Facebook, made me think I should really [...]
  • Negative Lookbehind – GREP for Designers This is the fourth and final blog-posts in a series of posts on lookaheads and lookbehinds in GREP, written after speaking at the Perth InDesign User Group. My speaker notes are also available: What is GREP? (PDF download) (2.4Mb). In the previous three posts I briefly introduced GREP, and we took a look at Positive [...]

2 Comments

  1. Cari Jansen Cari Jansen
    October 9, 2010    

    @Arlene ha-ha manual sorting is now a thing of the past 🙂 you might find some of the other scripts useful as well.

  2. October 8, 2010    

    I must thank you for this little tidbit. I’ve always wondered if there was a way and there was! My life is better because of it.

    Cheers!

Leave a Reply

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