Copy link to clipboard
Copied
Hi,
I converted some text to a table using this:
function ConvertoTable(){
var myStory = app.selection[0].parentStory;
var myTexts = myStory.texts[0];
//We now can convert that "texts" object to a table:
//Both arguments are separated by a "comma"
myTexts.convertToTable("\t","\r");}
I will always have the same kind of data with 3 columns, one with a mark/value, then a name, then a description.
I need to sort my table first by the first column in descending order (99 to 90) and then by name in ascending order(A to Z).
I will then export this table once it's sorted again as a text but it's an another story .
I know that you can do it through Indesign but I would want to automate it. My javascript is really rusted and I've just started to play with the greps and the scripts within Indesign...so I was hoping someone could help me to achieve that?
Thanks guys,
Michael A.
Copy link to clipboard
Copied
40 people viewing this post and still no answer?
Am I too impatient or too lazy? or both?
Copy link to clipboard
Copied
@Feeltheday – sorting tables is not that funny 😉
Hm. Too lazy? Just a suggestion…
As a starting point look into the following blog posts and scripts:
Peter Kahrel
InDesign: Sort tables | Peter Kahrel
And when it comes to language specific sort:
Language-aware paragraph/line sorter (light) | Peter Kahrel
Here the heavy-lifting:
Language-aware paragraph/line sorter | Peter Kahrel
Marc Autret
Indiscripts :: Alphabetical Sort in JavaScript (and InDesign)
Forum discussion here:
SortParagraphs Rules Do Not Follow Standards
Uwe
Copy link to clipboard
Copied
Thank you very much for these links. Going to dig a bit more then!
If all of that is just the starting point...yes this sorting tables thing seems to be less and less funny
Copy link to clipboard
Copied
@Michael – for a general purpose script as indicated with the ScriptUI window showing in your screenshot it is a huge task. At the same time you are narrowing the cases by describing a special set of data you want to sort, which is easier (not easy!). And a special kind of table (no merged cells, no formatted text).
But, there is this language aware sorting, that you want to do as well.
Well, you could look into Marc Autret's TCollator library doing pre-processing, if there are no languages involved like "Russian" or "Indian" etc.pp. You can look up a list of the supported languages at his blog post. And do also read the comments section.
Uwe
Find more inspiration, events, and resources on the new Adobe Community
Explore Now