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
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!