Solved

Link to display alphabetically

Posted on 2003-11-14
12
218 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In this article, I show you step by step with screenshots to assist you - HOW TO: Deploy and Install the VMware vCenter Server Appliance 6.5 (VCSA 6.5), with some helpful tips along the way.
A Short Story about the Best File Recovery Software – Acronis True Image 2017
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now