JSPM

  • Created
  • Published
  • Downloads 2711
  • Score
    100M100P100Q115492F
  • License MIT

A JavaScript client-side HTML table sorting library with no dependencies required.

Package Exports

  • table-sort-js
  • table-sort-js/table-sort.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (table-sort-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

table-sort-js table-sort-js table-sort-js table-sort-js table-sort-js

TABLE-SORT-JS.

Install instructions.

Option 1. 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 React.js and Vue.js

Option 2. Download table-sort.js (Select save as.), or download a minified version (~5kB)

Then add the following script before your HTML table:

<script src="table-sort.js"></script>

Refer to the documenation for examples on how to use table-sort-js with HTML

To make tables sortable:

  • Add class="table-sort" to HTML <table> tags.
  • Click on table headers to sort columns.

Classes:

<table> classes Description
"table-sort" Make the table sortable! (Words, numbers)...
"table-arrows" Display ascending or descending triangles.
"no-class-infer" Turns off inference for adding sort classes automatically (file-size-sort and runtime-sort).
"remember-sort" If clicking on different columns remembers sort of the original column.
<th> classes Description
"order-by-desc" Order by descending on first click. (default is aescending)
"data-sort" Sort by data attributes, e.g <td data-sort="42">
"onload-sort" Sort column on loading of the page. Simulates a click from the user. (can only sort onload for one column)
"file-size-sort" Sort file sizes(B->TiB) uses the binary prefix. (e.g KiB)
"runtime-sort" Sorts runtime in minutes and seconds e.g (1m 20s). Useful for sorting the GitHub actions Run time column...
"disable-sort" Disallow sorting the table by this specific column.
"alpha-sort" Sort alphabetically (z11,z2); default is natural sort (z2,z11).
"punct-sort" Sort punctuation; default ignores punctuation.

Development:

If you wish to contribute, install instructions can be found here.