Hello,
I have a Pick, Group, and Rank question and I am looking to return a sorted list using JavaScript. My code is as follows:
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
var choice = [
["${q://QID1/ChoiceNumericEntryValue/Rank/1}","${q://QID1/ChoiceDescription/1}"],
["${q://QID1/ChoiceNumericEntryValue/Rank/2}","${q://QID1/ChoiceDescription/2}"],
["${q://QID1/ChoiceNumericEntryValue/Rank/3}","${q://QID1/ChoiceDescription/3}"],
["${q://QID1/ChoiceNumericEntryValue/Rank/4}","${q://QID1/ChoiceDescription/4}"]
];
choice.sort(function(a, b){return a - b});
Qualtrics.SurveyEngine.setEmbeddedData('first',choice[0][1]);
Qualtrics.SurveyEngine.setEmbeddedData('second',choice[1][1]);
Qualtrics.SurveyEngine.setEmbeddedData('third',choice[2][1]);
Qualtrics.SurveyEngine.setEmbeddedData('fourth',choice[3][1]);
});
For some reason, even after doing choice.sort, I just get a static result of
ChoiceDescription/1
ChoiceDescription/2
ChoiceDescription/3
ChoiceDescription/4
in that order without any sorting, and regardless of what was put into the block. Can someone help me to figure out why it's not sorting my rankings? Thank you in advance for your help.
Choice Sort Function
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.

Not sure, what is not working here.
Even if I answer the following:
I get the following result after putting the javascript into a blank question on a new block on the next page:
Sorry for being difficult!