Program needed to sort a table in the chronological order

R

RG007

Columns are generated dynamically. They do not contain any dates.
They contain tags like 1b for 1 business day and 2b for 2 business
days, 1m for 1 month , 2y for 2 yrs etc... That will be a part of the
column name and not the full column name.
I need to sort that in the chronological order as 1b,2b, 1m, 2m, 3m,
1y,2y,etc... How to do that in JSP?
 
T

tom fredriksen

RG007 said:
Columns are generated dynamically. They do not contain any dates.
They contain tags like 1b for 1 business day and 2b for 2 business
days, 1m for 1 month , 2y for 2 yrs etc... That will be a part of the
column name and not the full column name.
I need to sort that in the chronological order as 1b,2b, 1m, 2m, 3m,
1y,2y,etc... How to do that in JSP?

you could use a days tag of days instead of 1b, 2b, 1m etc, you use
1..365. That way you can sort it by using normal tools. If the tags
needs to be displayed for some reason, attach a text which can be used
for each tag or group of tags.

/tom
 
?

=?ISO-8859-1?Q?Marcin_Jask=F3lski?=

RG007 said:
Columns are generated dynamically. They do not contain any dates.
They contain tags like 1b for 1 business day and 2b for 2 business
days, 1m for 1 month , 2y for 2 yrs etc... That will be a part of the
column name and not the full column name.
I need to sort that in the chronological order as 1b,2b, 1m, 2m, 3m,
1y,2y,etc... How to do that in JSP?

Have a look at:

java.util.Comparator interface and
void java.util.Arrays.sort(Object[] arg0[], Comparator arg1)

Basically, a class implementing the Comparator interface is used to
define an order on objects. You will have to implement method comparing
the column names to your liking.
Then... just call the sort method :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top