Jasbir21
asked on
Link to display alphabetically
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
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
How are the links stored?
You could use Arrays.sort() or Collections.sort().
You could use Arrays.sort() or Collections.sort().
Sorry, forget about that. Wait 1 minute
;-)
Jimmack and I always post on top of each other ;-)
And yes, he is right.
And yes, he is right.
ASKER
hi,
the links are like this:
<a target='mypopup' href='popup.jsp?organizati onid=<%=rs .getString ( "organname") %>'><%=rs.getString("organ name")%></ a>
the links are like this:
<a target='mypopup' href='popup.jsp?organizati
ASKER
how do i use Arrays.sort() or Collections.sort().
Do something like this:
import java.util.Vector;
import java.util.Collections;
Vector v = new Vector();
while (rs.next()){
String organname=rs.getString("or ganname");
v.add(organname);
}
Collections.sort(v);
for (int i=0; i<v.size(); i++){
out.println("<a target='mypopup' href='popup.jsp?organizati onid="+v.e lementAt(i )+">'>"+v. elementAt( i)+"</a>";
}
Hope it helps,
Nic
import java.util.Vector;
import java.util.Collections;
Vector v = new Vector();
while (rs.next()){
String organname=rs.getString("or
v.add(organname);
}
Collections.sort(v);
for (int i=0; i<v.size(); i++){
out.println("<a target='mypopup' href='popup.jsp?organizati
}
Hope it helps,
Nic
I dont know if this solution fits to your db, but hopefully you get the idea.
Otherwise let me know.
Otherwise let me know.
ASKER
hi,
I tried that :
..........part of the code:
do
{
String organname=rs.getString("or ganname");
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?organizati onid="+v.e lementAt(i )+"'>"+v.e lementAt(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
I tried that :
..........part of the code:
do
{
String organname=rs.getString("or
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?organizati
%>
<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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you very much
In what form are your links? Are the Strings or...?
Could you write a few example links?