Copy link to clipboard
Copied
I want to sort the data into form fields. The fields are arranged in a simple table with 10 rows and 3 columns with the headings "Number", "Name" and "Reward". I have the fields "pNum.0" ... "pNum.9", "name.0" ... "name.9" and "rew.0" ... "rew.9".
After filling in the fields I want to click on the "sort" button and sort the filled rows alphabetically according to the "Name" column. Names are also accented, eg "Šimon", "Čeněk" ...
Copy link to clipboard
Copied
Hi,
Here is a good script to sort raw data in your fields alphabetically.
Not sure how this may behave with accentuated names or words but see how this work for you:
Copy link to clipboard
Copied
This link lands to the forum home page… (https://community.adobe.com/)
😞
Copy link to clipboard
Copied
Thank you for the tip, but the script is written for LiveCycle Designer and therefore I neither see it nor know if I could use it in a form created in Acrobat.
Copy link to clipboard
Copied
I apologize I am editing my last reply
Copy link to clipboard
Copied
.
Copy link to clipboard
Copied
In French language we only have accented vowels (no consonants), and alphabetic sorts always happen correctly.
Copy link to clipboard
Copied
The linked sorting stuff is great, thanks for posting it, but unfortunately it's for XFA forms. Not Acrobat forms.
Copy link to clipboard
Copied
Here you go kamil,
I found this link from a very old thread back in 2009 in which a user named John Brinkman
shared sample of his form with the script in it:
https://blogs.adobe.com/formfeed/2009/05/sort_subforms.html
Another useful thread here with assumed answer:
https://forums.adobe.com/thread/1908385
and here with correct answer:
https://forums.adobe.com/thread/888025#3931407
Hope this helps.
Copy link to clipboard
Copied
All these scripts are written for LiveCycle Designer, they are useless if I am not mistaken.
Copy link to clipboard
Copied
You can edit the "compare" function to replace all accented characters with non-accented ones before comparing the two strings.
I believe that will solve your problem.
For example:
var names = ["Simon", "Šimon", "Simona", "Šimona", "Albert", "Zazie"];
names.sort(compare)
console.println(names)
function compare(a, b) {
a = replaceAccentedChars(a);
b = replaceAccentedChars(b);
if (a[0] < b[0]) {
return -1;
}
if (a[0] > b[0]) {
return 1;
}
return 0;
}
function replaceAccentedChars(s) {
s = s.replace(/Š/g, "S");
return s;
}
The output is:
Albert,Simon,Šimon,Simona,Šimona,Zazie
Without replacing the accented chars the output is:
Albert,Simon,Simona,Zazie,Šimon,Šimona
Copy link to clipboard
Copied
PS. Your compare function is not very good, in my opinion, as it only compares the first letter. That means that if you compare "Simon" with "Simona" it won't actually compare them but just return the first value each time.
I recommend you change it to comparing the full strings.
Copy link to clipboard
Copied
Thank you for the tip, but I have no idea how to do it. Can you help me, please?
Copy link to clipboard
Copied
Just remove all of the instances of "[0]"...
Copy link to clipboard
Copied
A side note: a simple solution may be practical for a single language or similar languages with the same rules. The actual rules for sorting strings are very complex and need knowledge of the language and sometimes other factors. Some rules will treat accented characters as equivalent to the unaccented; others expect the accented characters to follow the unsorted characters, or to be somewhere completely different in the order list. There are many special rules, such as mu-pi in Greek which is two letters which, appearing together sort somewhere else, or that ä in German is treated as if ae was written. Some languages have multiple rules in competition. Some languages sort more characters in between common letters. Going between upper and lower case is also language dependent. In much of the world I and i are equivalent but not in Turkey where the equivalent of I is a dotless i. So... define where you need this to work!
Copy link to clipboard
Copied
Very true. Since the OP did not specify how they want the texts to be sorted I had assumed it was as if the characters were not accented. If that's not the case then a different approach has to be taken, of course.
Copy link to clipboard
Copied
This is Czech. The order of the Czech alphabet is as follows: A B C Č D Ď E F G H Ch I J K L M N Ň O P Q R Ř S Š T Ť U V W X Y Z Ž. I don't care if it's case sensitive. Thank you very much for your interest.
Copy link to clipboard
Copied
The "Ch" part is not going to work... You'll need to add a special condition for it. For example, replace it with just "H" for the purpose of comparison.
Copy link to clipboard
Copied
After all this advice I still have no idea how to do it ... 😞 I need to sort accented data in a form created in Adobe Acrobat. I'm not a programmer. I need a specific code.
Copy link to clipboard
Copied
This is a serious programming exercise. Unlikely you will find anything already made to copy and paste. It is also not an exercise for a beginning programmer, there are several different issues of some complexity.
Copy link to clipboard
Copied
If you're interested I could write the full script for you, for a small fee. You can contact me via [try6767 at gmail.com] to discuss it further.