![table-sort-js](https://img.shields.io/github/workflow/status/leewannacott/table-sort-js/Jest%20CI%20-%20Automated%20testing%20of%20table%20sorting.?label=tests)
TABLE-SORT-JS.
Install instructions - pick one option.
- Install from npm:
npm install table-sort-js
import tableSort from "table-sort-js/table-sort.js";
Refer to the documentation for examples on using TABLE-SORT-JS with frontend frameworks such as
ReactJS.
- Download table-sort.js (Select save as.)
Then add the following script before your HTML table:
<script src="table-sort.js"></script>
Refer to the documenation for examples how to use TABLE-SORT-JS with HTML.
To make a table sortable:
- Add
class="table-sort"
to HTML <table> tags. Click on the columns heads to sort.
Classes:
table classes | Description |
---|
"table-sort" | Make the table sortable! (Words, numbers, dates) |
"table-arrows" | Display ascending or descending triangle. |
th classes | Description |
---|
"order-by-desc" | Order by descending on first click. (default is aescending) |
"file-size" | Sort file sizes(B->TiB) uses the binary prefix. (e.g KiB) |
Notes:
- Makes use of natural sorting to sort numerical values correctly.
- If
<thead>
does not exist it will be created by using data from first row. <tbody>
is optional.