The definitive source of the best
JavaScript libraries, frameworks, and plugins.

  • ×

    :arrow_up_down: A small tablesorter in plain JavaScript
    Filed under 

    • 🔾49%Overall
    • 1,086
    • 26.5 days
    • 🕩185
    • 👥18


    A small & simple sorting component for tables written in JavaScript

    Build Status npm version

    Quick start

    Download the ZIP of this repository or install via command line:

    npm i tablesort 
    # Or if you're using Yarn 
    yarn add tablesort
    <script src='tablesort.min.js'></script>
    <!-- Include sort types you need -->
    <script src='tablesort.number.js'></script>
    <script src=''></script>
      new Tablesort(document.getElementById('table-id'));

    See usage and demos for more

    Browser Support

    Chrome logo Firefox logo Internet Explorer logo Opera logo Safari logo
    8+ ✔ 3.6+ ✔ 10+ ✔ 11.50+ ✔ 5.1+ ✔


    // npm install tablesort
    var tablesort = require('tablesort');
    tablesort(el, options);

    Default CSS

    Add the styling from tablesort.css file to your CSS or roll with your own.

    Extending Tablesort

    If you require a sort operation that does not exist in the sorts directory, you can add your own.

    Tablesort.extend('name', function(item) {
      // Regular expression to test against.
      // `item` is a table value to evaluate.
      return /foo/.test(item);
    }, function(a, b) {
      // Custom sort functionality goes here.
      // e.g var n = (a > b) ? -1 : 1;
      return n;

    If you've made an extend function that others would benefit from pull requests are gladly accepted!


    Dependencies: Node.js 16 or 18; npm 8.

    Tablesort relies on Grunt as its build tool. Simply run npm run build to package code from any contributions you make to src/tablesort.js before submitting pull requests.

    Tests are run via:

    npm ci && npm t




    Create an issue

    Show All