Raymond Camden posted an article that helped me a lot just now when I was going to write a CTE in my stored procedure to retrieve the data sorted according to the client request.
His example of using JQuery is very explanatory and he makes use of the TableSort JQuery plugin by Christian Bach.
You may see it at Ray’s blog.