views:

292

answers:

6

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.

+1  A: 

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.

Mark A. Nicolosi
There is a lot of truth here for initial sorting, but what about resorting based on user interaction?
Shane C. Mason
If there's a lot of data, ajax could very well be faster than doing it all in javascript.
Mark A. Nicolosi
+1  A: 

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.

Bauer
+1  A: 

Have you tried tablesorter (powered by jQuery)?

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

It's pretty easy to use.

Sbm007
A: 

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

Shane C. Mason
A: 

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

James Black
+1  A: 

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.

Chi