Sorting data in a pdf form
Copy link to clipboard
Copied
I have a pdf form with rows and columns of data. I am looking for a solution for when the data comes in and is not in numerical order. I would like to be able to sort the data in the form based on a value in a column of data named 'outlets.0', 'outlets.1', etc. All associated rows have the same ending value (.....'.0') so I should be able to group the data together. I can use a button to call a javascript action. I have many functions in the form already but I'm not certain on where to even begin with this one. Will I need to
- loop through the rows, and pull the data into a hash
- make the key of the hash the column (hashes can be sorted by their keys in Perl, so I assume it’s the same)
- redistribute the data into the rows
or would there be a more simple way?
Copy link to clipboard
Copied
The second step you described is not how it's done in JavaScript. You will need to write a custom sort function and then call the sort method of the Array object you've created in the first step to sort it according to your desired parameters.
The rest is pretty much as you've written. The only thing that's missing is deciding what should trigger this operation. You say "when the data comes in" but that's pretty vague. Is this data being imported into the file? Entered by the user? Calculated automatically? Something else?
Copy link to clipboard
Copied
Will the values need to be stored temporarily before it can be sorted? The data is being entered by the user and is sent in for review. I am fine with initializing the function with a manual function button once the review is complete.
Copy link to clipboard
Copied
Yes, you'll have to save the data into an in-memory array variable to be able to sort it.

