4 Replies Latest reply: Nov 8, 2011 10:26 AM by [Jongware] RSS

    [CS3] Indexing, sort order and spaces

    GeraldHlasgow

      Hi,

       

      Can anyone tell me if it's possible to get the indexing in CS3 to treat a space as a significant character in terms of the sort order. An example:

       

      If I've got two names, say Cilla Black and Tony Blackburn as well as the phrases 'Black and White', 'Black Mountain' and word 'Blacken' I would expect to find the entries in the order

       

      Black and White

      Black, Cilla

      Black Mountain

      Blackburn, Tony

      Blacken

       

      In other words 'black<space>' comes before 'blacka' which in turn comes before 'blackb' and so on.  I've checked the indexes in a number of books and they all do this kind of thing.

       

      But in InDesign, the topics come out in the order

       

      Black and white

      Blackburn, Tony

      Black, Cilla

      Blacken

      Black Mountain

       

      So it seems to be ignoring the comma and the space and sorting as though

       

      blackandwhite

      blackburntony

      blackcilla

      blacken

      blackmountain

       

      Is there any way to stop it doing this short of setting up some very specific sort key values (e.g. black1, black2, black3) which are highly likely to get broken if I add further items to the index?

       

      Thanks.

        • 1. Re: [CS3] Indexing, sort order and spaces
          pkahrel Community Member

          InDesign sorts its indexes letter by letter, while what you want is word by word -- for details, see http://www.kahrel.plus.com/indesign/sort.html

          Unfortunately, you can't change that behaviour in InDesign itself. But using the sorter in that link you can choose a sort strategy. That sorter, by the way, is a paragraph sorter, so if you have any subtopics you'd have to combine topics and subtopics into one paragraph, then sort, then resore the subtopics. It's not ideal (and slow), but at least it gives you the result you want (or a very close one, anyway).

           

          Peter

          • 2. Re: [CS3] Indexing, sort order and spaces
            GeraldHlasgow Community Member

            Thanks, Peter.

             

            I'll take a look at the script, but I suspect - as I do have quite a number of entries with sub-topics (and possibly some with sub-sub-topics) - that it might be just as easy for me to write my own code to handle it in the specific way I need it to work, now that you've clarified that I really can't do it in InDesign.

            • 3. Re: [CS3] Indexing, sort order and spaces
              Caleb Clauset

              The 'trick' to getting InDesign to consider white-space is to copy the first word of any multi-word index entry into its Sort By attribute. For example:

               

              Black and White (sort by "Black")

              Black, Cilla (sort by "Black")

              Black Mountain (sort by "Black")

              Blackburn, Tony (sort by "Blackburn")

              Blacken

               

              will result in your desired sort order.

              • 4. Re: [CS3] Indexing, sort order and spaces
                [Jongware] Community Member

                Caleb Clauset wrote:

                 

                The 'trick' to getting InDesign to consider white-space is to copy the first word of any multi-word index entry into its Sort By attribute.

                 

                It does?

                 

                (Javascript:)

                 

                idx = app.activeDocument.indexes[0].allTopics;

                for (i=0; i<idx.length; i++)

                {

                          if (idx[i].sortOrder == '')

                                    idx[i].sortOrder = idx[i].name.match(/^[^ ]+/)[0];

                }

                 

                Edit: the comma should not be there in "Black, Cilia":

                 

                idx = app.activeDocument.indexes[0].allTopics;
                for (i=0; i<idx.length; i++)
                {
                          if (idx[i].sortOrder == '')
                                    idx[i].sortOrder = idx[i].name.match(/^[^ ]+?[^, ]+/)[0];
                }
                

                 

                 

                 

                Yup, it does. I learnt something new today!

                 

                Message was edited by: [Jongware]