Suppose I have two tables A and B and each one has only 1 column.
Each row in table A corresponds to each row in B, but I don’t want them to be in one table.
A B
------ ----------
car automobile
bike train
When I sort A alphabetically I should get
A B
------ ----------
bike train
car automobile
Since the items in table A have a one-to-one correspondence to the items in table B, it’s better to use an object to represent this data. An array of these objects represents the entire dataset. Whenever a sort is needed, just sort this array, and repopulate the tables.
Then create a custom sort function that only compares the property
firstfor sorting an array ofTransporterobjects.And a test run:
When the sort is done, update both tables.
Or, alternatively use any existing script or plugin. Here’s one for jQuery: http://tablesorter.com/docs/