A sorting component for HTML tables
npm install tablesorttablesort
---
A small & simple sorting component for tables written in JavaScript


`` html
`
---
|
|
|
|
|
|
|:---:|:---:|:---:|:---:|:---:|
| 8+ ✔ | 3.6+ ✔ | 10+ ✔ | 11.50+ ✔ | 5.1+ ✔ |
` js
import tablesort from 'tablesort';
tablesort(el, options);
`
If you require a sort operation that does not exist
in the 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!
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:
`sh`
npm test
Running the demo locally
`sh``
jekyll serve
Then open http://localhost:4000/demo/ (or whatever port it uses).
MIT