How to implement sort in pagination?

Hi all,
I have a table contains 400 records…
I used to display one page 10 records at a time (using pagination).

Now i want to add sort options like;
2.Record No
3.Most Visited

But these will be no effect on pagination…

How to do this?

Can any one give me the example to do this?

Thanking you…

Get your paginated results, then sort the supplied result set as you wish. As opposed to paginating a sorted result set.

One possible solution is to use tablesorter which does most of the work for you on the client side.

If you mean you want the user to click say a little down arrow next to a column name, then pass the column name as well to the script that does your pagination so it can include that column name in an “order by” clause in the query that gets the records for that particular page.