I think this should do what you want - return only the group names in one line.
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){// Identify this questionvar thisQuestion = $('#question{QID}');// Define the group scoresvar scores ={
G1:{equation1},
G2:{equation2},
G3:{equation3},
G4:{equation4},
G5:{equation5}};// Sort the arrayvar tuples =[];for(varkey in scores) tuples.push([key, scores[key]]);
tuples.sort(function(a, b){
a = a[1];
b = b[1];return a < b ? -1:(a > b ? 1:0);});// Loop through the sorted array for(var i =0; i < tuples.length; i++){varkey= tuples[i][0];var value = tuples[i][1];// Display in question text
$('.question-text', thisQuestion).append(key+' ');// Insert into textarea
$('textarea', thisQuestion).val($('textarea', thisQuestion).val()+key+' ');}});</script>
Cheers,
Tony Partner Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: InfoSolutionsProvider