Reputation: 8148
With the increasing popularity of powerful client side javascript widgets, I am curious on when is the best time to handle the sorting of data strictly on the client side, making use of widgets such as those found in YUI, and when to make a request to the backend and have it handle the sorting via a DB query or other means.
Upvotes: 1
Views: 277
Reputation: 37655
Except for exceptional cases, sort in the browser. Exceptional cases would be irrationally long lists, strange sorting rules requiring a host resource, insufficient javascript coding skills, etc. But there's not much to be gained from unnecessary round-tripping.
Very seldom does it make sense to download to the user more data than can comfortably be scrolled; and lists of this size should sort quite comfortably in the browser.
Upvotes: 0
Reputation: 70001
Another thing to think about is if you want to do a grouped sort or sort by a value and then translate that value into something human readable (ie unixtime), then it might be quicker and simpler to sort on the server.
Upvotes: 0
Reputation: 58804
It really depends what you're sorting, whether the client will require all of the data or only a sorted subset at any one time, and how expensive the sort actually is.
Upvotes: 1
Reputation: 13031
Personally, I would probably sort it on a postback. But if all your data is displayed on the page, then sorting via JS might provide a more responsive UI.
Upvotes: 0
Reputation: 351586
It depends on the amount of data - the best thing to do is to test and see which is faster.
Upvotes: 2