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:
- Checking browser console for JavaScript errors
- Temporarily disabling other plugins to test for conflicts
- Ensuring the Table Features for Site Visitors are enabled on the table's Edit screen
- 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
-
Dates Not Showing in Correct orderhttps://wordpress.org/support/topic/dates-not-showing-in-correct-order/
-
Number sorting issuehttps://wordpress.org/support/topic/number-sorting-issue/
-
Sorting columns as numerichttps://wordpress.org/support/topic/sorting-columns-as-numeric/
-
TablePress default sortinghttps://wordpress.org/support/topic/tablepress-default-sorting-3/
-
Multi Filter Headingshttps://wordpress.org/support/topic/multi-filter-headings/
-
Sorting symbols are messed uphttps://wordpress.org/support/topic/sorting-symbols-are-messed-up/
-
Sorting Disabled With columnDefshttps://wordpress.org/support/topic/sorting-disabled-with-columndefs/
-
position of arrows in sort-functionhttps://wordpress.org/support/topic/position-of-arrows-in-sort-function/
-
Sorting issue with INRhttps://wordpress.org/support/topic/sorting-issue-with-inr/
-
how to use it to show the woocommece orders pagehttps://wordpress.org/support/topic/how-to-use-it-to-show-the-woocommece-orders-page/
-
Tabelle nach Datum sortierenhttps://wordpress.org/support/topic/tabelle-nach-datum-sortieren/
-
UK Dates Sort Not Working with TablePresshttps://wordpress.org/support/topic/uk-dates-sort-not-working-with-tablepress/
-
Table Sort Not Workinghttps://wordpress.org/support/topic/table-sort-not-working-2/
-
Get undefined when adding specific text to cellshttps://wordpress.org/support/topic/get-undefined-when-adding-specific-text-to-cells/
-
Tablepress not sorting correctlyhttps://wordpress.org/support/topic/tablepress-not-sorting-correctly/
-
Reverse sort?https://wordpress.org/support/topic/reverse-sort/
-
TablePress sort only one columnhttps://wordpress.org/support/topic/tablepress-sort-only-one-column/
-
sorting column in descending formhttps://wordpress.org/support/topic/sorting-column-in-descending-form/
-
columndefs for RFC 2822 (or ideally most flexible) date sort?https://wordpress.org/support/topic/columndefs-for-rfc-2822-or-ideally-most-flexible-date-sort/
-
Sort when creating a tablehttps://wordpress.org/support/topic/sort-when-creating-a-table/
-
Date sort not workinghttps://wordpress.org/support/topic/date-sort-not-working-3/
-
Column not sorting correctlyhttps://wordpress.org/support/topic/column-not-sorting-correctly/
-
Sorting imageshttps://wordpress.org/support/topic/sorting-images-5/
-
Alphabetical orderhttps://wordpress.org/support/topic/alphabetical-order-35/
-
Sort Aarows gonehttps://wordpress.org/support/topic/sort-aarows-gone/
-
sort by last namehttps://wordpress.org/support/topic/sort-last-name/
-
Sorting with “merged” columnshttps://wordpress.org/support/topic/sorting-with-merged-columns/
-
lines got mixed uphttps://wordpress.org/support/topic/lines-got-mixed-up/
-
Sort Feature does’t appear on mobilehttps://wordpress.org/support/topic/sort-feature-doest-appear-on-mobile/
-
Combining DataPress Parametershttps://wordpress.org/support/topic/combining-datapress-parameters/
-
TablePress Sorting Issuehttps://wordpress.org/support/topic/tablepress-sorting-issue-2/
-
Row Grouping default sorthttps://wordpress.org/support/topic/row-grouping-default-sort/
-
Sortinghttps://wordpress.org/support/topic/sorting-59/
-
Sorting does not work – content disappearshttps://wordpress.org/support/topic/sorting-does-not-work-content-disappears/
-
numerical sortinghttps://wordpress.org/support/topic/numerical-sorting-4/
-
sorting columns by date not workinghttps://wordpress.org/support/topic/sorting-columns-by-date-not-working/
-
Sort Features box not displayinhttps://wordpress.org/support/topic/sort-features-box-not-displayin/
-
Sort Table By Datehttps://wordpress.org/support/topic/sort-table-by-date/
-
sorting dissapears on adding any code to custom fieldshttps://wordpress.org/support/topic/sorting-dissapears-on-adding-any-code-to-custom-fields/
-
Sort by Imageshttps://wordpress.org/support/topic/sort-by-images/
-
Sorting by UK datehttps://wordpress.org/support/topic/sorting-by-uk-date/
-
Sorting Numbers from Shortcodehttps://wordpress.org/support/topic/sorting-numbers-from-shortcode/
-
Table Sort Function not workinghttps://wordpress.org/support/topic/table-sort-function-not-working/
-
Sort by Month Namehttps://wordpress.org/support/topic/sort-by-month-name/
-
Columns with mixed numbers and letters don’t sort properlyhttps://wordpress.org/support/topic/columns-with-mixed-numbers-and-letters-dont-sort-properly/
-
Row ordering only works in Gutenberg editor; visitor sorting not workinghttps://wordpress.org/support/topic/row-ordering-only-works-in-gutenberg-editor-visitor-sorting-not-working/
-
Sort function not working in backendhttps://wordpress.org/support/topic/sort-function-not-working-in-backend/
-
Can’t Sort Table in Backendhttps://wordpress.org/support/topic/cant-sort-table-in-backend/
-
Remove the default sorting of table.https://wordpress.org/support/topic/remove-the-default-sorting-of-table/
-
Sorting issuehttps://wordpress.org/support/topic/sorting-issue-17/
-
Column Management – Sorting and hidinghttps://wordpress.org/support/topic/column-management-sorting-and-hiding/