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 7939107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:59:58+00:00 2026-06-03T22:59:58+00:00

I have 2 tables, one table has 2 columns, the other table has 1

  • 0

I have 2 tables, one table has 2 columns, the other table has 1 column. When you click on a row, that row is removed from the table and a new TR is added to the end of the opposite table. Now I want to sort it alphabetically.

jQuery plugins like tablesorter are total overkill for what I want to do. Is there a simple way I can sort the table?

Edit: Fiddle

  • 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-06-03T22:59:59+00:00Added an answer on June 3, 2026 at 10:59 pm

    Here you have a simple table sorter with a Fiddle demo here:

    HTML

    <table id="sort-table">
        <tbody>
            <tr><td>he</td></tr>
            <tr><td>stackoverflow</td></tr>
            <tr><td>by</td></tr>
            <tr><td>vote</td></tr>
            <tr><td>post</td></tr>
            <tr><td>And</td></tr>
            <tr><td>clicking</td></tr>
            <tr><td>up</td></tr>
            <tr><td>did</td></tr>
        </tbody>
    </table>
    <br>
    <button class="sort-table asc">sort ASC</button>
    <button class="sort-table desc">sort DESC</button>
    

    JQUERY

    $('.sort-table').click(function(e) {
        e.preventDefault();                    // prevent default behaviour
    
        var sortAsc = $(this).hasClass('asc'), // ASC or DESC sorting
            $table  = $('#sort-table'),        // cache the target table DOM element
            $rows   = $('tbody > tr', $table); // cache rows from target table body
    
        $rows.sort(function(a, b) {
    
            var keyA = $('td',a).text();
            var keyB = $('td',b).text();
    
            if (sortAsc) {
                return (keyA > keyB) ? 1 : 0;  // A bigger than B, sorting ascending
            } else {
                return (keyA < keyB) ? 1 : 0;  // B bigger than A, sorting descending
            }
        });
    
        $rows.each(function(index, row){
          $table.append(row);                  // append rows after sort
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Screenshot mockup: http://tinypic.com/r/y2qex/5 Problem: I have a table that has 53 columns; one for
I have a table column where each row has one of three states, and
I have a table which has several one to many relationships with other tables.
I have query table copyQuery which has Soil Condition has one of the columns,
I have a table with one column and four rows. Each tr has a
I have a table of many values where one column has the WO Number,
I have a dataset with multiple tables. One table in particular has one record
I have two tables, one is a table of forum threads. It has a
Lets say I have one table called REVIEWS This table has Reviews that customers
I have one table that has sales records and another table that has additional

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.