Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 577423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:09:05+00:00 2026-05-13T14:09:05+00:00

Suppose I have two tables A and B and each one has only 1

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:09:06+00:00Added an answer on May 13, 2026 at 2:09 pm

    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.

    // first represents the item in table A
    // second represents the item in table B
    function Transporter(first, second) {
        this.first = first;
        this.second = second;
    }
    

    Then create a custom sort function that only compares the property first for sorting an array of Transporter objects.

    function compare(a, b) {
        if(a.first < b.first) {
          return -1;
        }
        else if(a.first > b.first) {
          return 1;
        }
        return 0;
    }
    

    And a test run:

    var transporters = [];
    transporters.push(new Transporter("car", "automobile"));
    transporters.push(new Transporter("bike", "train"));
    
    console.log(transporters); // [0] => (car:automobile), [1] => (bike:train)
    transporters.sort(compare);
    console.log(transporters); // [0] => (bike:train), [1] => (car:automobile)
    

    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/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have two tables that are linked (one has a foreign key to
I have two tables - 'business' and 'business_contacts'. The business_contact table has a many-to-one
I want to have one table with two TIMESTAMP columns. One column to keep
Suppose I have a tags table with two columns: tagid and contentid . Each
Suppose I have two SQL tables: Customers and PhoneNumbers. Suppose that Customers has the
I have five combo boxes. Each one has a different name, but the possible
Suppose I have two tables, one with blog posts and another with readers and
Suppose I have two tables on a database, T 10 and T 11 ,
Suppose I have a dataset with those two immortal tables: Employee & Order Emp
Suppose we have the contents of tables x and y in two dataframes in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.