• Stars
    star
    1,087
  • Rank 40,923 (Top 0.9 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 12 years ago
  • Updated 2 months ago

Reviews 4.0 (1)

9 months ago by Marc Anguera

Lightweight and useful package to sort your HTML tables. Easily customizable via data-* attributes.

Repository Details

↕️ A small tablesorter in plain JavaScript

tablesort

A small & simple sorting component for tables written in JavaScript

Build Status npm version

Quick start

Download the ZIP of this repository or install via command line:

npm i tablesort 
# Or if you're using Yarn 
yarn add tablesort 
<script src='tablesort.min.js'></script>

<!-- Include sort types you need -->
<script src='tablesort.number.js'></script>
<script src='tablesort.date.js'></script>

<script>
  new Tablesort(document.getElementById('table-id'));
</script>

See usage and demos for more


Browser Support

Chrome logo Firefox logo Internet Explorer logo Opera logo Safari logo
8+ ✔ 3.6+ ✔ 10+ ✔ 11.50+ ✔ 5.1+ ✔

Node/Browserify

// npm install tablesort
var tablesort = require('tablesort');

tablesort(el, options);

Default CSS

Add the styling from tablesort.css file to your CSS or roll with your own.

Extending Tablesort

If you require a sort operation that does not exist in the sorts directory, you can add your own.

Tablesort.extend('name', function(item) {

  // Regular expression to test against.
  // `item` is a table value to evaluate.
  return /foo/.test(item);
}, function(a, b) {

  // Custom sort functionality goes here.
  // e.g var n = (a > b) ? -1 : 1;
  return n;
});

If you've made an extend function that others would benefit from pull requests are gladly accepted!

Contributing

Dependencies: Node.js 16 or 18; npm 8.

Tablesort relies on Grunt as its build tool. Simply run npm run build to package code from any contributions you make to src/tablesort.js before submitting pull requests.

Tests are run via:

npm ci && npm t

Licence

MIT

Bugs?

Create an issue

More Repositories

1

hoverintent

🐭 Fire mouse events when a user intends it
HTML
329
star
2

hcl-picker

🎨 Colorpicker for data
JavaScript
202
star
3

suggestions

A typeahead component for inputs
JavaScript
44
star
4

vim-sparkup

[Depreciated] Sparkup for Vim
Python
43
star
5

superman

🎨 A dark theme for Vim
Vim Script
20
star
6

deep-linking

⚓ A deep linking and highlighting UI
JavaScript
18
star
7

forrest

💼 Geocode data with ease
JavaScript
16
star
8

dotfiles

My config
Shell
11
star
9

forsythe

A tall sans font in normal & bold
Shell
11
star
10

datepickr

The do it yourself date picker
JavaScript
9
star
11

inverted-polygons

A friendly app for inverting polygons
JavaScript
8
star
12

leaflet-interact-intent

Interact with a map when a user intends it.
JavaScript
8
star
13

map-palette

Drag and drop or choose a palette to style a map
CSS
5
star
14

ender-dragdealer

Ender integration for Ovidiu Chereches excellent drag based javascript component.
JavaScript
5
star
15

geojson-to-image

Pass GeoJSON and get an image in return from Mapbox Static API
JavaScript
4
star
16

tristen.github.com

HTML
4
star
17

toronto-map

A TileMill map of Toronto.
4
star
18

maplist

Create a list of things on a map!
JavaScript
3
star
19

picture-map

WIP
JavaScript
3
star
20

vintages

Search LCBO's catalogue of vintages fast.
JavaScript
3
star
21

sotmus2015

CSS
2
star
22

map-controls

JavaScript
2
star
23

mm-examples

A prototype code examples site using Jekyll with gists and bl.ocks
JavaScript
2
star
24

wookie

Basic HTTP cookie handling.
JavaScript
2
star
25

scholar

Scholar is a Drupal starter theme for the University of Toronto
PHP
1
star
26

stream-o-tweet

Streams a tweet using socket.io and node-twitter.
JavaScript
1
star
27

radioplay

A one page interactive that demonstrates wax and layer switching
JavaScript
1
star
28

toronto-open-data

toronto.ca/open data converted into readable formats for GitHub
1
star
29

regex-js

An expression editor/visualizer
JavaScript
1
star
30

tilemill-tablesort

A plugin that adds sorting to the data features table
JavaScript
1
star
31

beamapper

web site to recruit mappers to OpenStreetMap.org
1
star
32

chart-to-map

Experimental utility for matching SVG elements to Mapbox GL style templates.
JavaScript
1
star
33

presentations

HTML
1
star
34

demos

JavaScript
1
star