multiple column sorting on JTable data

if any body can please send an example code how multiple column sorting can be done on table data.

condition:- one column should sort in ascending order another column in descending order.

am completly out of ideas it's urgent any help is greatly appritiated

Thank's in advance

sri

[314 byte] By [srinathnma] at [2007-10-3 10:30:27]
# 1
Crosspost! http://forum.java.sun.com/thread.jspa?threadID=788223&tstart=0
PhHeina at 2007-7-15 5:53:08 > top of Java-index,Desktop,Core GUI APIs...
# 2

I think the crosspost is because the OP was advised to post it in the Swing forum instead (it would've been nice to see the original post closed as well, though). Anyway...

Have you got your table sorting using one column? If so, how have you achieved that (eg, are you using Java 6)?

All you're after is a stable sorting algorithm so that any elements that are the same in the new sorting scheme stay in the same position relative to each other. Then you can just sort by "Column B" then "Column A" to achieve multiple column sorting. I believe that Collections.sort is stable and therefore any sorting approach based on that should be easily modifiable to do what you want.

Hope this helps.

KPSeala at 2007-7-15 5:53:08 > top of Java-index,Desktop,Core GUI APIs...