tablesorter_js
A lightweight, jQuery 4 compatible client-side table sorting module for Drupal 11+. Add class "tablesorter" to any table to enable click-to-sort on column headers.
Motivation
The Tablesorter module uses the Mottie tablesorter library, which is not compatible with jQuery 4. Drupal 11 ships with jQuery 4, causing JavaScript errors.
The Mottie library uses .bind() and .unbind() methods (~100+ instances) which were removed in jQuery 4. The maintainer stated they would keep using deprecated methods for backwards compatibility. See issue #3517103.
This module provides a simple replacement (~70 lines) covering core sorting functionality.
When to Use This Module
Use when you have:
- Small to medium tables displayed entirely on the page
- Static content that doesn't need database queries on sort
- Simple sorting needs (text and numeric columns)
Do NOT use when you have:
- Large datasets with thousands of rows
- Paged tables where sorting should re-query the database
- Complex needs (custom parsers, multi-column sort, filters)
For server-side sorting, use Drupal core's TableSort.
Features
- Client-side sorting - no page reload
- Automatic numeric vs text detection
- Handles currency ($1,234.56) and percentages
- Keyboard accessible (Enter/Space)
- ARIA attributes for screen readers
- Automatic zebra striping (odd/even classes)
- jQuery 4 compatible (Drupal 11+)
- ~70 lines of code
Post-Installation
Add class tablesorter to any table with a <thead>. Works automatically with Tablefield's "sortable" option.
Additional Requirements
None. Uses only Drupal core libraries (jQuery, Drupal, once).
Similar projects
- Tablesorter - Uses Mottie library, not jQuery 4 compatible
- DataTables - Full-featured but heavier; not yet Drupal 11 compatible
- Drupal core TableSort - Server-side only (page reload)