Back to Community

Fixing TablePress Date and Number Sorting Issues: A Troubleshooting Guide

Content

If you're using TablePress for WordPress and struggling with tables that won't sort dates or numbers correctly, you're not alone. This common issue typically occurs when TablePress interprets your data as text rather than numerical values or proper date formats. Based on community discussions, here are the most effective solutions to resolve sorting problems in your tables.

Why TablePress Sorting Fails

TablePress relies on the DataTables JavaScript library for frontend sorting functionality. By default, DataTables attempts to automatically detect column data types, but it can be confused by:

  • Date formats that don't match US standards (MM/DD/YYYY)
  • Numbers mixed with text characters (like "100 Mbps")
  • Special characters or diacritics in alphabetical sorting
  • Empty rows or cells in the table data
  • Incorrect quotation marks in custom commands

Common Solutions for Sorting Problems

1. Install the DataTables Sorting Plugins Extension

For non-US date formats and complex sorting scenarios, the TablePress team recommends installing the official DataTables Sorting plugins extension. This free add-on provides additional sorting algorithms specifically designed for various date formats and special data types.

2. Use Custom Commands for Date Sorting

For date sorting issues, add the appropriate custom command to your table's settings:

For UK/European dates (DD/MM/YYYY):

"columnDefs": [ { "type": "date-eu", "targets": [ 2 ] } ]

For US dates (MM/DD/YYYY):

"columnDefs": [ { "type": "date", "targets": [ 2 ] } ]

For ISO dates (YYYY-MM-DD):

"columnDefs": [ { "type": "date", "targets": [ 0 ] } ]

Note: The number in "targets" refers to the column index, starting with 0 for the first column.

3. Set Default Sorting Order

To make your table sort by a specific column automatically when the page loads, combine commands:

"columnDefs": [ { "type": "date-eu", "targets": [ 2 ] } ], "order": [ [ 2, "asc" ] ]

4. Fix Number Sorting Issues

When numbers sort incorrectly (e.g., 100 appearing after 20), check for:

  • Hidden characters or text mixed with numbers
  • Empty cells that might disrupt type detection
  • Consistent data formatting throughout the column

5. Check for Common Configuration Errors

  • Quotation marks: Ensure you're using straight quotes (") not curly quotes (“ ”)
  • Empty rows: Delete any completely empty rows in your table
  • Header requirement: The sorting feature requires a table header row to be enabled
  • Plugin conflicts: Some ad plugins (like Ezoic) or optimization plugins may break sorting functionality

When Sorting Still Doesn't Work

If you've tried these solutions without success, consider:

  1. Checking browser console for JavaScript errors
  2. Temporarily disabling other plugins to test for conflicts
  3. Ensuring the Table Features for Site Visitors are enabled on the table's Edit screen
  4. Verifying that your table doesn't contain merged cells, which can disrupt sorting

Most sorting issues can be resolved with proper configuration of the custom commands and ensuring data consistency throughout your table. The TablePress extension system provides robust solutions for even the most complex sorting requirements.

Related Support Threads Support