Solved

Link to display alphabetically

Posted on 2003-11-14
12
222 Views
Last Modified: 2010-04-01
hi,
  I have an application when the user enter search the links gets displayed.

How do i do it, if i want to display link alphabetically,
For example:

if user enter little, big
should be displayed like this

big

little

Thanks
0
Comment
Question by:Jasbir21
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 1

Expert Comment

by:JNic
ID: 9752147
Hi,

In what form are your links? Are the Strings or...?

Could you write a few example links?
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9752149
How are the links stored?

You could use Arrays.sort() or Collections.sort().
0
 
LVL 1

Expert Comment

by:JNic
ID: 9752151
Sorry, forget about that. Wait 1 minute
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 15

Expert Comment

by:jimmack
ID: 9752153
;-)
0
 
LVL 1

Expert Comment

by:JNic
ID: 9752158
Jimmack and I always post on top of each other ;-)

And yes, he is right.

0
 

Author Comment

by:Jasbir21
ID: 9752183
hi,
the links are like this:

<a target='mypopup' href='popup.jsp?organizationid=<%=rs.getString( "organname") %>'><%=rs.getString("organname")%></a>

0
 

Author Comment

by:Jasbir21
ID: 9752186
how do i use Arrays.sort() or Collections.sort().
0
 
LVL 1

Expert Comment

by:JNic
ID: 9752314
Do something like this:

import java.util.Vector;
import java.util.Collections;

Vector v = new Vector();
while (rs.next()){
  String organname=rs.getString("organname");
  v.add(organname);
}
Collections.sort(v);
for (int i=0; i<v.size(); i++){
   out.println("<a target='mypopup' href='popup.jsp?organizationid="+v.elementAt(i)+">'>"+v.elementAt(i)+"</a>";
}

Hope it helps,

Nic
0
 
LVL 1

Expert Comment

by:JNic
ID: 9752400
I dont know if this solution fits to your db, but hopefully you get the idea.
Otherwise let me know.
0
 

Author Comment

by:Jasbir21
ID: 9752441
hi,

I tried that :

..........part of the code:
     do
         {

String organname=rs.getString("organname");
if(!v.contains(organname)){

v.add(organname);

Collections.sort(v);
for (int i=0; i<v.size(); i++){

   out.println("<a target='mypopup' href='popup.jsp?organizationid="+v.elementAt(i)+"'>"+v.elementAt(i)+"</a>");



%>



<br>


<%


}
}
         }while(rs.next());
     }
.........

I don't know why duplicate links are being displayed eventhough i put a distict link in sql statements as well as
if(!v.contains(organname))

and the link are not displaying ailphabetically.

Did i miss anything, thanks
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 150 total points
ID: 9752988
you can simple append " order by organname" to the end of your sql statement.
0
 

Author Comment

by:Jasbir21
ID: 9753039
thank you very much

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
oracle fusion vs MQ 2 122
thymeleaf natural templating vs JSP 2 141
difference between sorce folder and folder in eclipise 3 29
collection output issue 9 39
Use Windows Task Scheduler to print a Word document weekly so your printer ink won't dry out.
Riverbed Technology's webinar discusses networking for the cloud era with simplified SD-WAN cloud connectivity.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question