Solved

Link to display alphabetically

Posted on 2003-11-14
12
224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A look at what happened in the Verizon cloud breach.
The recent Petya-like ransomware attack served a big blow to hundreds of banks, corporations and government offices The Acronis blog takes a closer look at this damaging worm to see what’s behind it – and offers up tips on how you can safeguard your…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

635 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