I have a large array, returned from a callserver to populate a select list,something like Option (value, label, 0,0) 75 deep. Can I easily sort on one column of this array ? Or do I need to sort it myself and keep the various columns in sync ? It is currently sorted on value, which is how the data is read, but the users want it sorted on the label.Tips/Pointers/RTFMs appreciatedAndy
Those examples show a one column array, this is a 4 column array & I needot keep the rows in sync. My thought is, if I need to put the value in a hash (by label) and then sort the label, finally determine selected or not. I would certainly do that in Perl. My other option is to ignore the request.
I build an array like this:newOptions = new Option(DCRLabels, DCRValues, false, false)I cannot sort one without making certain that the other columns are correct. So if I cannot sort this array on Column 1 (DCRLabels), then I need to change how I build the list.
//Declarevar newOptions = new Array; // Populate it...for (var i=0; i<DCRLabels.length; i++) { newOptions = new Option(DCRLabels, DCRValues, false, false);}// Sort PopulatednewOptions.sort(byText); // Note - what you've called "Label" is Option's Class text Attribute// OR newOptions.sort(byValue);function byText(a, b) { return a.text > b.text;}function byValue(a, b) { return a.value > b.value;}