Should data sorting be done on the client or on the server?
Each approach has its pros and cons:
- If you need pagination, and don't want to download the entire data to the client, then you must perform the sorting on the server (otherwise the client can only sort the rows it currently has, which will lead to wrong results, if you re-sort by a different column)
- Sorting on the server is faster (as in: you can sort more rows/second), but if you have to serve 10000 clients at once, this may easily invert.
- When sorting on the client, you can re-sort without downloading the data again.
Ideally, the sort should be done on the server because:-
It is best to assume that your client will be having low resources. For example, some people will launch the GWT app from a desktop but another may launch the GWT app from a iPad/phone which is having less CPU/RAM
There are standard ways to do sorting on the server side, for example, by using SQL ORDER BY clause but you may have to implement your own routine/method to do the sorting on the client side.
It depends... :)
- How much data is to be sorted? How fast? "fast as possible" ok... what's the slowest you can accept? Can the client handle this? What about the server? What other responsibilities do these elements have and does this create conflict?
- How reliably must the data be sorted? For example, if the data were not sorted sometimes would this be OK?
- How are the responsibilities allocated to the elements in your architecture? For that matter, what are the elements? Do you have a database? What about a business tier? The world could be more complex than just "client vs. server"
- How will the data be used? Will multiple sorts need to be performed? For example, A->Z and Z->A?
- Is the cost of transferring data between the client and server reasonable? Are there other ways to make it reasonable?
Architecturally speaking, to answer this question you need to decide on the desired properties in your system and evaluate the trade-offs among various design alternatives. Without knowing more about your system it is difficult to offer advice beyond this.