1.21.0 • Published 1 month ago

table-sort-js v1.21.0

Weekly downloads
36
License
MIT
Repository
github
Last release
1 month ago

npm version npm downloads jsDeliver downloads repo size MIT licence code style: prettier build status

TABLE-SORT-JS.

Install instructions.

  • Option 1: Load as script from a Content Delivery Network (CDN):
<script src="https://cdn.jsdelivr.net/npm/table-sort-js/table-sort.min.js"></script>

Or non-minified version (larger size, but easier to debug!):

<script src="https://cdn.jsdelivr.net/npm/table-sort-js/table-sort.js"></script>

Example on how to use table-sort-js with HTML

  • Option 2: Install from npm:
npm install table-sort-js
import tableSort from "table-sort-js/table-sort.js";

Examples on using table-sort-js with frontend frameworks such as React.js and Vue.js

To make tables sortable:

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

Classes:

<table> classesDescription
"table-sort"Make the table sortable! (Words, numbers, dates, file sizes)...
"no-class-infer"Turns off inference for adding sort classes automatically i.e (file-size-sort, runtime-sort, dates-dmy-sort).
"table-arrows"Display ascending or descending triangles.
"remember-sort"If clicking on different columns remembers sort of the original column.
"cells-sort"sort cells (td) rather than table rows (tr); useful for keeping table rows with classes/attributes in place.
<th> classesDescription
"data-sort"Sort by data attributes, e.g <td data-sort="42">. Useful for doing custom sorts.
"dates-mdy-sort"Sorts dates in US style mm/dd/yyyy format;. e.g (12/28/2023). Can use "/" or "-" as separator. Overides inferred "dates-dmy-sort" class.
"onload-sort"Sort column on loading of the page. Simulates a click from the user. (can only sort onload for one column)
"disable-sort"Disallow sorting the table by this specific column.
<th> Inferred Classes.Description
"numeric-sort"Sorts numbers including decimals - Positive, Negative (in both minus and parenthesis representations).
Supports common currencies e.g ($£€¥) and percentage signs e.g (0.39%)
"dates-dmy-sort"Sorts dates in dd/mm/yyyy format. e.g (18/10/1995). Can use "/" or "-" as separator.
"dates-ymd-sort"Sorts dates in ISO 8601 yyyy/mm/dd format. e.g (2021/10/28). Use "/" or "-" as separator.
"file-size-sort"Sorts file sizes(B->TiB) uses the binary prefix. (e.g 10 B, 100 KiB, 1 MiB); optional space between number and prefix.
"runtime-sort"Sorts runtime in hours minutes and seconds e.g (10h 1m 20s). Useful for sorting the GitHub actions Run time column...
<th> Classes that change defaults.Description
"order-by-desc"Order by descending on first click. (default is aescending)
"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.

1.21.0

1 month ago

1.19.0

2 months ago

1.20.0

2 months ago

1.18.3

4 months ago

1.18.2

5 months ago

1.18.1

10 months ago

1.18.0

11 months ago

1.17.0

12 months ago

1.15.0

12 months ago

1.14.0

12 months ago

1.13.0

12 months ago

1.12.1

1 year ago

1.11.2

1 year ago

1.12.0

1 year ago

1.10.2

1 year ago

1.15.2

12 months ago

1.16.0

12 months ago

1.15.1

12 months ago

1.9.1

1 year ago

1.8.2

1 year ago

1.9.0

1 year ago

1.9.2

1 year ago

1.8.1

1 year ago

1.8.0

2 years ago

1.7.9

2 years ago

1.6.9

2 years ago

1.6.8

2 years ago

1.5.8

3 years ago

1.4.7

3 years ago

1.3.7

3 years ago

1.3.7-a

3 years ago

1.3.7-e

3 years ago

1.3.7-d

3 years ago

1.3.7-c

3 years ago

1.3.7-b

3 years ago

1.2.7

3 years ago

1.1.6-d

3 years ago

1.1.6-c

3 years ago

1.1.6-b

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago