Can you do this in Microsoft Word?...

Can you sort a list and disregard ‘a’, ‘an’, and ‘the’ in the titles?

In other words, can you sort…

A League of Their Own
The Godfather
The Big Lebowski
A Night at the Opera

…into…

The Big Lebowski
The Godfather
A League of Their Own
A Night at the Opera

I want to sort a long list and I’d like to avoid having to do this:

Big Lebowski, The
Godfather, The
League of Their Own, A
Night at the Opera, A

Or worse, have it end up like this:

A League of Their Own
A Night at the Opera
The Big Lebowski
The Godfather
Thanks,

mmm

It would be possible to create a macro that would (1) move the articles to the end of each paragraph in one swell foop, as in your example of “League of Their Own, A”; (2) sort the list; and (3) put the articles back at the beginning of the titles. A knowledge of wildcard search-and-replace would be required. Sorry, but I don’t have time to create such a macro for you, but if you know someone who’s adept with wildcards, Bob’s your uncle.

Hm, on second thought, wildcards may not be required. But you would have to know some VBA.

I was thinking that you could copy the list to a second column. Do a search and replace to eliminate the leading article (search for ^pThe[space], ^pA[space] and ^pAn[space]) and then delete the leading article only on the new column. Sort the list by the new column and the delete it.

Ditto what Dewey Finn said. I would just add more detail: Covert your list to a table with one column, and each title in a row; copy the whole column to a second column; edit ONE of the columns as Dewey explained; sort by the edited column; delete the edited column; convert the remaining column back to text.

Maybe I’m a geek, but I would do this:

Copy the list into Excel
Use a formula to create a second column in the format you desire, moving the article to the end of the title.
The formula would start like this:

if(left(A1,2) = "A ",right(A1,len(a1)-2) & “, A”,… more formulae in here for other combinations…)

Sort that column.

Use similar formulae to convert back.

I’m going to inspire hatred if I explain how trivial it is to do this with a single regexp in Perl or Awk, aren’t I?

Stranger

Speaking of Word issues, why the hell doesn’t Word spell-check when in form-filling mode? You know, when you’re filling in the gray form field.

What a major pain in the ass that is to me now that half my work is completed in this regard.

If you mean that you’re creating the forms, you could use this code.

That looks pretty nifty, but no, I’m just filling the forms in, not creating them.

I agree that Dewey Finn’s suggestion is the fastest, easiest way to get this done.

I never understood why Microsoft completely ignores such an industry standard like regexp and insists on implementing its own lame pattern matching in Word. I often copy text into a text editor that supports regexp, edit it, and paste it back to Word.

Maybe because those ‘industry standard’ regular expressions didn’t exist at the time Word was created?

Thanks for playing, but no. Microsoft Word evolved from about 1983 onward, introducing the modern Word for Windows in 1989. Regular expressions have been a feature in various Unix applications such as expr and awk, and in the Bourne shell since the 1970s. Ironically, the basis for Word was originally written in Xenix, which was the Microsoft-licensed version of Unix. Microsoft could have implemented a regexp-type matching and replacement in Word any time they wanted to; instead, they went with the hobbled MS-DOS wildcard matching and simplistic find and replace routines.

Admittedly, this is a feature that the vast majority of Word users could not use even if they knew it existed. But for those of us who are aware, it is a substantial pain in the ass that Word cannot do these kind of search, or any of a variety of other context-specific or user-defined-rules-based expressions.

Stranger

To be fair, Word does have a pattern-matching feature that has evolved beyond DOS wildcards, but the notation is klunky, it can’t capture portions of the matched pattern to use in the Replace string, and it’s unique to Word without providing any added value.

So it’s better than * ? but not nearly as powerful as regexp. Regexp is available in the free NoteTab Light, as one example. So if those guys can do it for free, MS should be able to do it.

ETA: And I was using regexp in 1980.

Wow, very elegant!