Question

I have seen a number of Javascript examples to throw on top of an html table to make them sortable. The issue is that everyone I have seen and tried are insanely slow.

Any suggestions or recommendation for a good performance solution.

Was it helpful?

Solution

I've found (just in casual use, not via any intensive analysis) that the jQuery TableSorter plug-in has a decent performance rate, and is quite advanced compared to any of the other solutions out there.

Of course, it relies on jQuery, but if you were picky about footprint you could analyse the method used by the plug-in and create your own lighter implementation.

OTHER TIPS

Have you tried tablesorter (powered by jQuery)?

Check it out at: http://tablesorter.com/docs/

It's pretty easy to use.

If this is for a web app and you have a lot of data, it may make more sense to do the sorting server-side using SQL or whatever ORM you're using.

The fastest way to sort that I found is to actually just sort the rows in the table. If you move a cell in the DOM the entire row will move, and so be sorted.

Here is a sample of doing this, as I don't remember the article I read about doing this originally. http://www.eggheadcafe.com/community/aspnet/3/10051794/try-this.aspx

I've spent a lot of time evaluating various advanced table libraries, including the jquery one, the dojo one, the YUI datatable, and GWT's paging scroll table. I was unsatisfied with the performance of any of them for tables with thousands of rows (and I think paging is a poor solution as well).
I concluded that flash is the way to go with this kind of scenario.

A site that gives an example of a flash table with 10000, 100000, and a million rows can be found here.

There is also this site, which allows you to compare the performance of a javascript and flash implementation of an advanced table.

Perhaps Javascript isnt the solution here then - you could do server side sorting or consider a flex/actionscript based solution.

I was using W3 School Sort plugin and it was really slow with a table of 250 rows. Unresponsive for a good 5 seconds.

Switched to tablesorter.com as mentionned in the replies. Works like a charm. Much, much faster. No wait at all now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top