Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

Program needed to sort a table in the chronological order

Thread view: 
RG007 - 23 Feb 2006 11:12 GMT
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?
tom fredriksen - 23 Feb 2006 13:03 GMT
> 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
Marcin Jaskólski - 23 Feb 2006 14:27 GMT
> 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 :-)

Signature

Pozdrawiam,
Marcin

Roedy Green - 23 Feb 2006 15:29 GMT
On Thu, 23 Feb 2006 15:27:48 +0100, Marcin Jaskólski
<no.email@provided.com> wrote, quoted or indirectly quoted someone who
said :

>Have a look at:
>
>java.util.Comparator interface and
>void java.util.Arrays.sort(Object[] arg0[], Comparator arg1)

see http://mindprod.com/jgloss/comparator.html
http://mindprod.com/jgloss/sort.html
http://mindprod.com/jgloss/generics.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.