# tablesort

> A sorting component for HTML tables

Latest version **5.7.1** (published 2026-04-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install tablesort
pnpm add tablesort
yarn add tablesort
bun add tablesort
```

## Health

**Score 45/100 (D)** — status: active.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 5.7.1 |
| Published | 2026-04-15 |
| First published | 2012-03-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 22 |
| Dependencies | 0 |
| Unpacked size | 515.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1143 |
| Author | tristen |
| Maintainers | tristen |

## Links

- npm: https://www.npmjs.com/package/tablesort
- Repository: https://github.com/tristen/tablesort
- Homepage: http://tristen.ca/tablesort/demo/
- Issues: https://github.com/tristen/tablesort/issues
- npm.io page: https://npm.io/package/tablesort

## Recent versions

- 5.7.1 (latest) — 2026-04-15
- 5.7.0 — 2025-12-26
- 5.6.0 — 2025-04-21
- 5.5.0 — 2025-03-24
- 5.3.0 — 2021-10-30
- 5.2.1 — 2020-06-03
- 5.2.0 — 2020-01-23
- 5.1.0 — 2018-09-14
- 5.0.2 — 2017-11-12
- 5.0.1 — 2017-05-27
- 5.0.0 — 2016-12-30
- 4.1.0 — 2016-07-23
- 4.0.1 — 2016-03-30
- 4.0.0 — 2015-12-17
- 3.2.0 — 2015-12-11
- … 29 more at https://npm.io/package/tablesort/versions

## README

tablesort
---

A small & simple sorting component for tables written in JavaScript

[![Build Status](https://app.travis-ci.com/tripu/tablesort.svg?branch=master)](https://app.travis-ci.com/tripu/tablesort)
[![npm version](http://img.shields.io/npm/v/tablesort.svg)](https://npmjs.org/package/tablesort)

### Quick start

``` html
<script src='tablesort.min.js'></script>

<!-- Include sort types you need -->
<script src='tablesort.number.js'></script>
<script src='tablesort.date.js'></script>

<script>
  new Tablesort(document.getElementById('table-id'));
</script>
```

**[See usage and demos for more](http://tristen.ca/tablesort/demo/)**

---

### Browser Support

| <img src="http://i.imgur.com/dJC1GUv.png" width="48px" height="48px" alt="Chrome logo"> | <img src="http://i.imgur.com/o1m5RcQ.png" width="48px" height="48px" alt="Firefox logo"> | <img src="http://i.imgur.com/8h3iz5H.png" width="48px" height="48px" alt="Internet Explorer logo"> | <img src="http://i.imgur.com/iQV4nmJ.png" width="48px" height="48px" alt="Opera logo"> | <img src="http://i.imgur.com/j3tgNKJ.png" width="48px" height="48px" alt="Safari logo"> |
|:---:|:---:|:---:|:---:|:---:|
| 8+ ✔ | 3.6+ ✔ | 10+ ✔ | 11.50+ ✔ | 5.1+ ✔ |

### Node/Browserify

``` js
import tablesort from 'tablesort';

tablesort(el, options);
```

### Default CSS
Add the styling from [tablesort.css](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](https://github.com/tristen/tablesort/tree/gh-pages/src/sorts/)
directory, you can add your own.

``` js
Tablesort.extend('name', item => {

  // Regular expression to test against.
  // `item` is a table value to evaluate.
  return /foo/.test(item);
}, (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!

### Contributing
Dependencies: Node.js 22.

Tablesort relies on [Grunt](http://gruntjs.com) 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:

```sh
npm test
```

Running the demo locally

```sh
jekyll serve
```

Then open http://localhost:4000/demo/ (or whatever port it uses).

### Licence

MIT

### Bugs?

[Create an issue](https://github.com/tristen/tablesort/issues)

---
_Source: https://npm.io/package/tablesort · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
