Specifying a Collating Sequence for Indexes

Written by Allen Wyatt (last updated February 5, 2022)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021


1

Barry has a document (for a thesis) with index entries (XE fields) of "Gen. 1:20", "Exo. 20:2", and "1 Thes. 4:14". When he generates the index, it comes out in alphabetical order (1 Thes. 4:14, Exo. 20:2, Gen. 1:20), but he wants it to be in biblical canonical order, i.e., Gen. 1:20, Exo. 20:2, 1 Thes. 4:14. Barry wonders if there is a way to change the collating sequence so that a document's index is not alphabetical.

The answer to this query is to use an esoteric (some say "undocumented") feature of Word that allows you to override how index entries are sorted. Consider the following index entry—a field—as created by Word:

{ XE "Exo. 20\:2" }

This entry was created by selecting the text "Exo. 20:2" (without the quote marks) and then marking it as an index entry. You can modify how Word sorts the index entry, however, by modifying the field code. Simply follow the entry with a semicolon and the way in which it should be sorted in the index, in this manner:

{ XE "Exo. 20\:2;02Exodus 20\:02" }

In this case I've assigned an arbitrary prefix of "02" before the book name (Exodus) to signify that this is the second book of the bible. I also modified the verse number from "2" to "02" so that any other index entries for the second chapter of Exodus will sort correctly in relation to each other.

I could also have gotten more cryptic with my index sorting code, in this manner:

{ XE "Exo. 20\:2;022002" }

In this case, the code means "book 02, chapter 20, verse 02." If I had actually wanted the scripture reference to be subordinate to a different entry, such as "Old Testament References," then the field code would need to be further expanded, in this manner:

{ XE "Exo. 20\:2;022002:Old Testament References" }

Note the treatment of the two colons in the field: The first one is "escaped out" by the inclusion of the backslash and the second one is not. The backslash is included so that Word understands the colon is not the demarcation between the entry and subentry portions of the field.

You can even go so far as to change the sorting entry of the subentry designation, using the same semicolon as you did in the main entry:

{ XE "Exo. 20\:2;022002:Old Testament References;Bible Verses 1" }

This example causes "Old Testament References" (which is what appears in the actual index) to be sorted as "Bible Verses 1". You could then, with New Testament References, use the sorting code of "Bible Verses 2", which means that they would appear after the Old Testament grouping, as they should.

With this sorting override trick under your belt, you could get creative with your index entries, but it will take a bit of work: every single index entry will need to be manually adjusted to include whatever pattern you want to use for your sorting. This can get tedious (as you might imagine), but you could make it easier by developing your own macros to do the field updating for you. Such a macro would depend on the sorting pattern you established and what you want, exactly, the macro to do. You really should, for example, have one that adds the sorting pattern you want and one that removes it.

You can find additional information about this approach to sorting index entries at the following websites:

https://buildabiblicalreferenceindexwithword.wordpress.com/
https://taxonomist.tripod.com/indexing/wordproblems.html#override

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (7545) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Storing AutoText Entries with a Document

AutoText entries can provide quite a bit of flexibility and power in a document. If you want to share those entries with ...

Discover More

Changing the Types of Numbers in a Numbered List

Ever want to change the types of numbers that Word displays when you create a numbered list? There are several numbering ...

Discover More

Selecting Text in Linked Text Boxes

Text boxes are often used as design elements in a document layout. If you have linked text boxes, you may have noticed ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More WordTips (ribbon)

Creating an Index Entry for a Range of Pages

Putting together an index for your documents can be challenging, but Word provides some great tools to make the task ...

Discover More

Specifying Index Section Dividers

When adding an index to your document, you can use one of the available field switches to specify how the index should be ...

Discover More

Indexing Based on a Range of Letters

Word provides many options for creating indexes. One option allows you to specify that the index contain only entries ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 2 + 2?

2022-02-07 09:15:15

Helen Playdon

Hooray, a Tip that I can not only understand but can see WHEN I might want to use it. Your choice of example was most apposite (my husband is theologian, so this is a problem I can relate to as I am his go-to person for how to do....). I often don't know although I can often find a way through the mire, even if not the best way, but this looks truly amazing! As one of the generation of teachers who found themselves in 1989 U.K. National Curriculum Mathematics) having to teach how to use spreadsheets and databases to 11-year-olds, without a moments training in them for ourselves, I have had o find out the hard way how to do most things. I managed to lead the staff, none of whom had a computer on which to practice, to teach these across the whole of the high school, achieving the best results in the county in the national exams, but without retaining much of the information thirty years later. At the moment every time I open Excel I get a blank screen, even on sheets I have been using for years. And I have been totally unable to open new ones.


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.