npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

table-sort-js

v1.21.0

Published

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

Downloads

2,989

Readme

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> 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. | | "cells-sort" | sort cells (td) rather than table rows (tr); useful for keeping table rows with classes/attributes in place. |

| <th> classes | Description | | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | "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.