I solved my original query, and have removed the original defective script from this post. The script below takes any set of selected objects and rearranges their stacking order so that the (vertically) topmost object is at the back of the stack, the vertically lowest at the front (and similarly for all intervening objects).
It should now replicate the action of JET_StackTopToBottom.jsx, which is apparently no longer available. I hope this may help anyone who, like me, would gladly have paid to find it!
David Entwistle
var thisDoc = activeDocument;
// get selected objects
var selObj = thisDoc.selection;
// count the selected objects
var selObjCount = selObj.length;
// sort selected objects by their height from the page origin
var byProperty = function(prop) {
return function(a,b) {
if (typeof a[prop] == "number") {
return (a[prop] - b[prop]);
} else {
return ((a[prop] < b[prop]) ? -1 : ((a[prop] > b[prop]) ? 1 : 0));
}
};
};
var symbolsSorted = selObj.sort(byProperty("top"));
// for each object in turn in the ordered selection, BringToFront
for(i = selObjCount; i >0; i--){
var currObj = symbolsSorted[i-1];
currObj.zOrder(ZOrderMethod.BRINGTOFRONT);
}
redraw();