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

Script to reorder pages in alphabetical order

New Here ,
Feb 05, 2021 Feb 05, 2021

Copy link to clipboard

Copied

Hi, I am currently trying to redorder pages based on names found within each page so I can alphabetize my document. I wrote a script that can find the name I am looking for and successfully store the name and that page number in an array of objects. I can see my search and sort function has been successful when I console.println my sorted array. however, using the this.movePage function to move the actual pages based off of my sorted (alphabetized) array has proven tricky since the page numbers are dynamic and moving one reorders the current document. Do you have a better suggestion on how to move the pages successfully?

TLDR: I have pages sorted in an array that I want the document order to resemble. How do I successfully use this.movePage to accomplish this? (Or is there another way?) Thanks in advance.

TOPICS
Windows

Views

76

Likes

Translate

Translate

Report

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
LEGEND ,
Feb 05, 2021 Feb 05, 2021

Copy link to clipboard

Copied

Rearranging any list suffers from this problem. Sometimes working backwards in the list solves it, but not here. The simplest solution, but probably not the most efficient, is to renumber your sort list after each move, to reflect the move you just did.

Likes

Translate

Translate

Report

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 ,
Feb 05, 2021 Feb 05, 2021

Copy link to clipboard

Copied

I recommend creating a new file and then adding the pages to it in the correct order.

Likes

Translate

Translate

Report

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
LEGEND ,
Feb 05, 2021 Feb 05, 2021

Copy link to clipboard

Copied

LATEST

Logically, that is a simpler solution to code, but my experience of moving pages singly between documents has been that it is very inefficient. May be ok for 20 pages, probably unacceptable for 2000. Result files are also sometimes much, much larger.

Likes

Translate

Translate

Report

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