While experimenting with different tablesorting jQuery plugins, I stumbled upon one that perfectly meets the following criteria:
- Correctly sorts dates
- Properly sorts numbers
- Sorts words representing numbers (e.g. One, Two, Three) accurately
- Sorts in a DOM-conscious manner. This means that if you update the content of a table cell and then click on the header to sort that column, it recognizes the new value instead of sorting based on the initial page load data. (this feature was particularly hard to find as popular tablesorters don't handle changes during runtime)
The only challenge I'm facing is that it seems to only sort the visible rows. I would like it to sort the entire table, not just the visible ones, while maintaining all the features mentioned above, especially the DOM-aware aspect, as this will be used on a table where user-generated data may be updated and sorted subsequently.
I intend to open-source this jQuery plugin so I'm happy to share the code here. The jQuery code provided below is mine, and the plugin I am using for sorting can be found here: http://www.kryogenix.org/code/browser/sorttable.
The code snippet below highlights the issue. You can click on any cell to edit inline and make changes to the DOM yourself.