Choice Group Sort | XM Community
Skip to main content

Hello,
I have a Pick, Group, Rank question I am trying to sort, but I am wanting to reference only one group and sort that specific list for the top 4 choices. How can I create an array based off of a list? Thank you so much for your help.
Qualtrics.SurveyEngine.addOnload(function()
{   
/*Place your JavaScript here to run when the page loads*/   
jQuery('#QID1').find('ul')(0].id;
jQuery('#QID1').find('ul')(1].id;

var choice = h
"${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}"],
];         
console.log(choice)
choice.sort();

Qualtrics.SurveyEngine.setEmbeddedData('first',choicet0]'1]);   
Qualtrics.SurveyEngine.setEmbeddedData('second',choiceD1]a1]);   
Qualtrics.SurveyEngine.setEmbeddedData('third',choiced2]d1]);   
Qualtrics.SurveyEngine.setEmbeddedData('fourth',choiceb3]d1]);

});


It can't be done with piping and sorting because there isn't a way to pipe statements by group.
The captureRanks function does it. If you are going to do it yourself, you would need to use a similar approach.


Leave a Reply