Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Sorting by "x" then by "y" my table (multiple criterias ascending and descending)

Explorer ,
Jun 04, 2014 Jun 04, 2014

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?

erk.jpg

Thanks guys,

Michael A.

TOPICS
Scripting
536
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 05, 2014 Jun 05, 2014

40 people viewing this post and still no answer?
Am I too impatient or too lazy? or both?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 05, 2014 Jun 05, 2014

@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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 05, 2014 Jun 05, 2014

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 05, 2014 Jun 05, 2014
LATEST

@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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines