Andrew said:

Say I have two arrays with the same number of elements that are

related: var a1 = [1,3,2];

var b2 = ["a","b","c"];

I need to sort a1 but have the order of the elements in b2 reflect the

any new order in a1. So if a1 sorts as

I haven't done extensive testing, but I threw this together:

var a1 = [1,3,2,5,4];

var a2 = ["a","b","c","d","e"];

var a3 = ["z","y","x","w","v"];

Array.prototype.multisort = function() {

var sortArray = [];

for (var i=0; i<this.length; i++) {

sortArray

* = [this**];*

for (var j=0; j<arguments.length; j++) {

if (arguments[j].length!=this.length) { return false; }

sortArray*[j+1] = arguments[j]**;*

}

}

sortArray.sort();

for (var i=0; i<sortArray.length; i++) {

this* = sortArray**[0];*

for (var j=0; j<arguments.length; j++) {

arguments[j]* = sortArray**[j+1];*

}

}

return true;

}

alert(a1+"\n"+a2+"\n"+a3);

a1.multisort(a2,a3);

alert(a1+"\n"+a2+"\n"+a3);

a2.multisort(a1,a3);

alert(a1+"\n"+a2+"\n"+a3);

a3.multisort(a1,a2);

alert(a1+"\n"+a2+"\n"+a3);

Let me know if it works for you.