How to sort accented data in form fields

New Here ,
Oct 19, 2019 Oct 19, 2019

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" ...

TOPICS
Acrobat SDK and JavaScript, How to, PDF forms, Windows

Views

142

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
Adobe Community Professional ,
Oct 19, 2019 Oct 19, 2019

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:

 

https://forums.adobe.com/thread/928087

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
Adobe Community Professional ,
Oct 20, 2019 Oct 20, 2019

Copy link to clipboard

Copied

This link lands to the forum home page…  (https://community.adobe.com/)

😞

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
New Here ,
Oct 21, 2019 Oct 21, 2019

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. 

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
Adobe Community Professional ,
Oct 21, 2019 Oct 21, 2019

Copy link to clipboard

Copied

I apologize I am editing my last reply

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
New Here ,
Oct 21, 2019 Oct 21, 2019

Copy link to clipboard

Copied

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
Adobe Community Professional ,
Oct 20, 2019 Oct 20, 2019

Copy link to clipboard

Copied

In French language we only have accented vowels (no consonants), and alphabetic sorts always happen correctly.

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
Most Valuable Participant ,
Oct 20, 2019 Oct 20, 2019

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.

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
Adobe Community Professional ,
Oct 21, 2019 Oct 21, 2019

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.

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
New Here ,
Oct 21, 2019 Oct 21, 2019

Copy link to clipboard

Copied

All these scripts are written for LiveCycle Designer, they are useless if I am not mistaken. 

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
Most Valuable Participant ,
Oct 21, 2019 Oct 21, 2019

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

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
Most Valuable Participant ,
Oct 21, 2019 Oct 21, 2019

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.

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
New Here ,
Oct 21, 2019 Oct 21, 2019

Copy link to clipboard

Copied

Thank you for the tip, but I have no idea how to do it. Can you help me, please?

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
Most Valuable Participant ,
Oct 21, 2019 Oct 21, 2019

Copy link to clipboard

Copied

Just remove all of the instances of "[0]"...

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
Most Valuable Participant ,
Oct 21, 2019 Oct 21, 2019

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!

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
Most Valuable Participant ,
Oct 21, 2019 Oct 21, 2019

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.

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
New Here ,
Oct 21, 2019 Oct 21, 2019

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.

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
Most Valuable Participant ,
Oct 21, 2019 Oct 21, 2019

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.

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
New Here ,
Oct 22, 2019 Oct 22, 2019

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.

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
Most Valuable Participant ,
Oct 22, 2019 Oct 22, 2019

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.

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
Most Valuable Participant ,
Oct 22, 2019 Oct 22, 2019

Copy link to clipboard

Copied

LATEST

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.

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