Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
table-sort-js
Advanced tools
A JavaScript client-side HTML table sorting library with no dependencies required.
Description: HTML table sorting library with sort type inference builtin and browser extension available. #VanillaJS
Documentation. (work in progress)
npm package. and jsDelivr
Firefox and Chrome browser extensions: Tables of any website you visit become sortable!
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
<script src="https://cdn.jsdelivr.net/npm/table-sort-js@latest/table-sort.js"></script>
Or Minified (smaller size, but harder to debug!):
<script src="https://cdn.jsdelivr.net/npm/table-sort-js@latest/table-sort.min.js"></script>
Refer to the documenation for examples on how to use table-sort-js with HTML
Then rename and add the following script before your HTML table:
<script src="table-sort.js"></script>
class="table-sort"
to HTML <table> tags.<table> classes | Description |
---|---|
"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. |
<th> classes | Description |
---|---|
"data-sort" | Sort by data attributes, e.g <td data-sort="42"> |
"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) |
"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. |
If you wish to contribute, install instructions can be found here.
FAQs
A JavaScript client-side HTML table sorting library with no dependencies required.
The npm package table-sort-js receives a total of 1,545 weekly downloads. As such, table-sort-js popularity was classified as popular.
We found that table-sort-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.