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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:02:13+00:00 2026-06-15T01:02:13+00:00

I have html, and jquery for sorting my table (also there is non-standart sorting

  • 0

I have html, and jquery for sorting my table (also there is non-standart sorting (with multi-tbody)).

My code could be found here: http://jsfiddle.net/GuRxj/

As you can see there, td with prices (on russian Цена) are sorted ascending (but tech-as not!? why? (it a question too))… But as you see, i need to send this tr’s with prices to top of this tbody (now there are in the bottom), while empty-price-tr send to bottom…
How to do this?

part of js:

$('.prcol').click(function(e) {
      var $sort = this;
      var $table = $('#articles-table');
      var $rows = $('tbody.analogs_art > tr',$table);
      $rows.sort(function(a, b){
          var keyA = $('td:eq(3)',a).text();
          var keyB = $('td:eq(3)',b).text();
            if (keyA.length > 0 && keyB.length > 0)
            {
              if($($sort).hasClass('asc')){
                  console.log("bbb");
                  return (keyA > keyB) ? 1 : 0;
              } else {
                console.log(keyA+"-"+keyB);
                  return (keyA > keyB) ? 1 : 0;
              }
            }
      });
      $.each($rows, function(index, row){
        //console.log(row);
        $table.append(row);
        //$("table.123").append(row);
      });
      e.preventDefault();
    });
  • 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-15T01:02:14+00:00Added an answer on June 15, 2026 at 1:02 am

    Fixed Demo http://jsfiddle.net/RwW9q/3/ or http://jsfiddle.net/tcZNH/

    Rest code should be clear to understand,

    Надеюсь, что это FIDS ваши потребности :) (hope it fits your need,)

    Code

    jQuery(function($) {
        var table = $('table');
        $(document).ready(function() {
            $('.prcol').click(function(e) {
                var $sort = this;
                var $table = $('#articles-table');
                var $rows = $('tbody.analogs_art > tr', $table);
                $rows.sort(function(a, b) {
                    var keyA = $('td:eq(3)', a).text().toUpperCase();;
                    var keyB = $('td:eq(3)', b).text().toUpperCase();;
    
                    if (keyA.length > 0 && isNaN(parseFloat($('td:eq(3)', b).text()))) return Ascending(keyA, keyB);
                });
                $.each($rows, function(index, row) {
                    //console.log(row);
                    $table.append(row);
                    //$("table.123").append(row);
                });
                e.preventDefault();
            });
        });
    });
    
    function Ascending(a, b) {
        if (a > b) return -1;
        if (a < b) return 1;
        return 0;
    }​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have html, and jquery for sorting my table (also there is non-standart sorting
I have the following html code with Jquery Sorting <div class=sortable style='width:700px; margin: 0
I have this html code that i want to edit with jQuery. Here is
I have an HTML table that I'm sorting with jQuery tablesorter. I have an
I have this html code <html> <head> <title>JQuery Problem 2</title> <script type=text/javascript src=jquery-1.4.min.js></script> <script
I am using James Padolsey's jQuery sorting script for a HTML table in an
I have some html and jQuery code as follows: $(function(){ $(#button).click(function(e){ $('.imgdiv').load('images3.php'); e.preventDefault(); });
I have a html jquery mobile multi-page and using swipeleft and swiperight events to
I have the following code to convert my JSON dataset to html table. I
I have a bit of HTML/JQuery code that only seems to be working for

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.