Since the elements of table A have a one-to-one correspondence with the elements of table B, it is better to use an object to represent this data. An array of these objects represents the entire data set. Whenever sorting is required, just sort this array and write down the tables.
function Transporter(first, second) {
this.first = first;
this.second = second;
}
, first Transporter.
function compare(a, b) {
if(a.first < b.first) {
return -1;
}
else if(a.first > b.first) {
return 1;
}
return 0;
}
:
var transporters = [];
transporters.push(new Transporter("car", "automobile"));
transporters.push(new Transporter("bike", "train"));
console.log(transporters);
transporters.sort(compare);
console.log(transporters);
, .
, , script . jQuery: http://tablesorter.com/docs/