Solution:
To achieve that, you have to zip both arrays in just one. This is, given you have this two array:
sortThis=[3,1,2];
sortAccording=["With 3","With 1","With 2];
After zip them, you will have the following array:
zipped = [{a: 3, b: "With 3"}, {a: 1, b: "With 1"}, {a: 2, b: "With 2"}];
Then, you sort it by a in order to have:
zippedAndSorted = [{a: 1, b: "With 1"}, {a: 2, b: "With 2"}, {a: 3, b: "With 3"}];
What next?
Well, once you have this array sorted by what you want, you have to extract their values with the map function and finnaly you will have your two arrays sorted by the same criteria:
The code:
// your arrays
sortThis=[3,1,2];
sortAccording=["With 3","With 1","With 2"];
// the zip function
function zip(a,b) {
return a.map(function(aa, i){ return { i: aa, j: b[i]};} )
};
// ziping and sorting the arrays
var zipped = zip(sortThis, sortAccording);
zippedAndSorted = zipped.sort(function(a,b){ return a.i - b.i; });
// your two sorted arrays
sortedThis = zippedAndSorted.map(function(a){ return a.i;});
sortedAccording = zippedAndSorted.map(function(a){ return a.j;});
You also can see it working here: http://jsfiddle.net/lontivero/cfpcJ/
Good luck!