About pagination

I have done an pagination code in a jsp page, now i have to sort according to column when clicked, can any give ideas.
[125 byte] By [uk0102a] at [2007-11-27 2:36:18]
# 1
There are 2 ways. 1) Issue an ORDER BY query on the database, or 2) Use Collections#sort() with kind of an DtoComparator to sort the List.
BalusCa at 2007-7-12 2:55:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Yes ,we can write an order by statement in the query but I am not able to get how to pass the (asc or desc) on clicking the column name

<tr align='center'>

<th><a href="" onclick="sort()">ID</a></th>

<th >Name</th>

<th>From </th>

is this right?

i have tried this way but it is not calling the function

uk0102a at 2007-7-12 2:55:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Add a boolean toggle.
BalusCa at 2007-7-12 2:55:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
you may want to try this:<a href="javascript://" onclick="sort(); return false;">ID</a>
gimbal2a at 2007-7-12 2:55:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Oh, now I see.Well, rather add the onclick to the <th> element. Using the <a> element to call javascript-only functions is discouraged.
BalusCa at 2007-7-12 2:55:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
thanks i will tryMessage was edited by: uk0102
uk0102a at 2007-7-12 2:55:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
As you already have the collection object with you, I guess using the comparator is a better and an easier way to handle this. Once you have your comparator in place, 'Collections.sort()' would do the remaining.SirG
SirGenerala at 2007-7-12 2:55:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...