Solved

Link to display alphabetically

Posted on 2003-11-14
12
221 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

This article outlines the process to identify and resolve account lockout in an Active Directory environment.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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 …

773 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