-2

I want to sort all values but jquery sorts only three values I want multiple table sort on tag h2 but when i sort it only sort first 3 values but i want all values

$('#alphBnt').on('click', function() {
  var sorting = $(".box").sort(function(a, b) {
    return $(a).find("h2").text() > $(b).find("h2").text();
  });

  $("#container").html(sorting)
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<p><button id="alphBnt">Sort</button></p>
<div id="container">
  <table border=2px class="box">

    <tr>
      <td class="name">
        <h1>mui</h1>
      </td>
      <td class="number">
        <h2>4512</h2>
      </td>
    </tr>
  </table>
  <table border=2px class="box">

    <tr>
      <td class="name">
        <h1>oinecellars</h1>
      </td>
      <td class="number">
        <h2>566</h2>
      </td>
    </tr>
  </table>
  <table border=2px class="box">

    <tr>
      <td class="name">
        <h1>zacchus </h1>
      </td>
      <td class="number">
        <h2>34566</h2>
      </td>
    </tr>
  </table>
  <table border=2px class="box">

    <tr>
      <td class="name">
        <h1>zacchus </h1>
      </td>
      <td class="number">
        <h2>1</h2>
      </td>
    </tr>
  </table>

  


</div>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
hello
  • 9
  • 3
  • I added a dot `$("#container").html(sorting)` and added jQuery. Please add CSS so we can see what you mean by grey – mplungjan Oct 05 '21 at 16:09
  • 1
    Where is the outer table? Also `` is invalid markup – mplungjan Oct 05 '21 at 16:11
  • Welcome to Stack Overflow! Please visit [help], take [tour] to see what and [ask]. Do some research, search for related topics on SO; if you get stuck, post a ***[mcve]*** of your attempt, noting input and expected output – mplungjan Oct 05 '21 at 16:13
  • Does this answer your question? [How may I sort a list alphabetically using jQuery?](https://stackoverflow.com/questions/1134976/how-may-i-sort-a-list-alphabetically-using-jquery) – Heretic Monkey Oct 05 '21 at 16:30
  • @HereticMonkey It's a numeric sort – mplungjan Oct 05 '21 at 16:38
  • @mplungjan Did you event look for a dupe? Many of the answers on that dupe will work fine. But if we're going to be picky and not search because we answered the question, [How to order (sort) a
  • list with numeric content?](https://stackoverflow.com/q/10215341/215552)
  • – Heretic Monkey Oct 05 '21 at 16:44
  • @HereticMonkey it was not obvious from the initial code so I did not look – mplungjan Oct 05 '21 at 17:00