Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Link to display alphabetically

Posted on 2003-11-14
12
Medium Priority
?
227 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 600 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

Independent Software Vendors: 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

Your business may be under attack from a silent enemy that is hard to detect. It works stealthily in the shadows to access and exploit your critical business information, sensitive confidential data and intellectual property, for commercial gain. T…
Mailbox Corruption is a nightmare every Exchange DBA wishes he never has. Recovering from it can be super-hectic if not entirely futile. And though techniques like the New-MailboxRepairRequest cmdlet have been designed to help with fixing minor corr…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

772 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