2

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.

3
  • How many rows are we talking about? Commented Sep 18, 2009 at 0:55
  • 1
    10,000? You are better off doing that on the server and replacing the table's body. Either way, the rendering of a 10000 row table would kill you if it is not paged. Commented Sep 18, 2009 at 11:03
  • I agree with epascarello. Older browsers might have difficult time merely rendering 10,000 rows. Paging seems like a good idea in this case. Commented Sep 18, 2009 at 15:59

7 Answers 7

3

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.

Sign up to request clarification or add additional context in comments.

Comments

3

Have you tried tablesorter (powered by jQuery)?

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

It's pretty easy to use.

1 Comment

Sadly, the tablesorter.com domain is now parked (e.g. a spammy ad site)
2

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.

2 Comments

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

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

Comments

1

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.

Comments

0

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

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.