JSFiddle - React, Tailwind, and code Playground

by csornmo

HTML

<table class="table">
  <thead>
    <tr>
      <th scope="col">#</th>
      <th scope="col" id="firstName">name</th>
      <th scope="col" id="points">Points</th>
      <th scope="col" id="date">Time</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td scope="row">1</td>
      <td class="firstName">Mark</td>
      <td>12</td>
      <td>300</td>
    </tr>
    <tr>
      <td scope="row">2</td>
      <td class="firstName">Jacob</td>
      <td>13</td>
      <td>100</td>
    </tr>
    <tr>
      <td scope="row">3</td>
      <td class="firstName">Mark</td>
      <td>12</td>
      <td>200</td>
    </tr>
  </tbody>

JavaScript

var sorted = $('#highscore-table tbody .highscore-player').sort(function(a, b) {
  var a = $(a).find('td:last-child').text(), b = $(b).find('td:last-child').text();
  return b.localeCompare(a, false, {numeric: true})
})