Copy link to clipboard
Copied
An index with 20k codes has to be sorted differently, considering only the first n (7 in my cae) digits.
Codes has variable number of digits (from 7 to 12 or more). I just need to order them ignoring anything above the 7th digit.
Thanks for help
Copy link to clipboard
Copied
This may be achievable with a script, but in my experience, very specialized tasks like this are better done by tools outside InDesign. Without knowing anything further, I'd use something like Excel to sort the list; just possibly Word.
Copy link to clipboard
Copied
Sorting is a built in script but it's quite basic as it lacks a function window wherr one could specify a filter to apply before sorting. Does anybody know about a better script? Going outside Indesign is a bad idea as many styles and objects applied would go... fishing.
Copy link to clipboard
Copied
ID scripts can be made quite complex and could probably handle it (I am a fledgling script guy at best, so I'm not the one to help with it.) My only concern is that 20,000 items is a lot, at least for InDesign... many of its capabilities have either modest data spans or slow way down past certain limits. Not sure if this one of those or not.
Some of the scripting gurus should check in soon on this. If not, I'll bump it to get their attention.
Copy link to clipboard
Copied
Hi,
Just a simplistic Script that includes in each entry a "sort by" as: the 7 first digits!
Best,
(^/) The Jedi
Copy link to clipboard
Copied
… Well! Something like this:
index with basically sorted (ID by default) entries:
What the op seems to want:
As you can see, the numbers are sorted basing on the first seven digits!
(^/)
Copy link to clipboard
Copied
Thank you although I can't figure out how it works. You use only the expression and there's no need to specify how many digits do you need? Well in my case the summary has produced a column with all the 20k lines as in the example hereunder:
In the meanwhile I tested SmartSort (https://indiscripts.com/category/projects/SmartSort)
It's a freeware and works much faster than the bundled Indesign's sorting javascript.
Although it has some customization options for the text, there's almost none when dealing with numbers.
The script's result (applied after objects cleansing) seems quite correct even without specifying the desired "n" value.
I have to test it deeper to see it's behaviour whith the tiny "new" object between the code and the page number.
Copy link to clipboard
Copied
Test completed, problem solved. The freeware script made the job. It's a pitty I still don't understend how in the detail, but the result is achieved.
Here's the screenshot of the result with the "New" object in it's place (it would have been a pain in the back to preserve it through an Excel sheet).
I.e. 061902202... is now in the correct position.
Thanks to "Indiscripts" and to the people who replied to my question. By the way I'd like to discover how to use (^/) and assign it's function to the first n-digits only.
Copy link to clipboard
Copied
Glad you've done it 🙂
This "New" icon wouldn't be a problem with the Excel way 😉 as long as it's the only icon 😉
You can search for Anchored Objects in the text:
Anchored Object Marker
Text - ^a
GREP - ~a
Unicode - U+FFFC
So you could change it to some text representation - "icon" , then after sorting - replace back with the same icon - copy icon to clipboard, then find "icon" text and replace with "^c".
Copy link to clipboard
Copied
What do you mean by Index?
If a list of codes - single code per line - the quickest way would be to copy to Excel, sort and paste back.
If there is more info associated with the code - it will be more complicated - but of course perfectly doable 😉