makineni_rk
asked on
How to sort data in table based on multiple Header Fields selected
I have to fill the JTable data with some date, time and string values. for example my table data looks like this:
"1998/12/14","15:14:38","U nicorn1"," row1"
"1998/12/14","15:14:39","U nicorn2"," row2" "1998/12/14","15:14:40","U nicorn4"," row3" "1998/12/17","12:14:12","U nicorn4"," row6"
Now the Sorted Table should be in the following way:
"1998/12/17","12:14:12","U nicorn4"," row6"
"1998/12/14","15:14:40","U nicorn4"," row3"
"1998/12/14","15:14:39","U nicorn2"," row2"
"1998/12/14","15:14:38","U nicorn1"," row1"
ie First Date field should be sorted, if 2 date fields are same then sort based on time. if date and time fields are same then need to be sorted on String field.
So if any one worked on this please theow some light on how to proceed. I know how to sort based on single column.
But now i need to sort a multiple columns.So what is code change in the Comparater class.
Thanks in advance.. This is urgent....
"1998/12/14","15:14:38","U
"1998/12/14","15:14:39","U
Now the Sorted Table should be in the following way:
"1998/12/17","12:14:12","U
"1998/12/14","15:14:40","U
"1998/12/14","15:14:39","U
"1998/12/14","15:14:38","U
ie First Date field should be sorted, if 2 date fields are same then sort based on time. if date and time fields are same then need to be sorted on String field.
So if any one worked on this please theow some light on how to proceed. I know how to sort based on single column.
But now i need to sort a multiple columns.So what is code change in the Comparater class.
Thanks in advance.. This is urgent....
ASKER
Hi MaxMaxic,
The data is not coming from the database. Assuming it as static data
rds,
ram
The data is not coming from the database. Assuming it as static data
rds,
ram
Hi.
You can try to sort first the least significant column and then go to next least significant column and etc'.
In your example it should be String field, time field, date field.
I hope it helps.
You can try to sort first the least significant column and then go to next least significant column and etc'.
In your example it should be String field, time field, date field.
I hope it helps.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Regards.