Sort a collection in alphabetic order

2003-03-10 Thread Søren Blidorf

Hi.
I need to sort my collection people in alphabetic order by lastname,
firstname.
Can anybody help me?

I guess I should do it in the Action and not when displayed in jsp page.



Collection people = new ArrayList();

while( rs.next() ) {
PeopleBean pb = new PeopleBean();
pb.setId(rs.getInt(ID));
pb.setFirstname( rs.getString( FIRSTNAME ));
pb.setLastname( rs.getString( LASTNAME ));
}

people.add( pb );


Søren Blidorf





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Sort a collection in alphabetic order

2003-03-10 Thread Dave Newton
On Mon, 2003-03-10 at 13:16, Søren Blidorf wrote:
 I need to sort my collection people in alphabetic order by lastname,
 firstname. Can anybody help me?

Most algorithm books will give you more information than you want on
sorting.

Why not just do it in the query and let the db do it?

Dave



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Sort a collection in alphabetic order

2003-03-10 Thread Robert Taylor
Do it in the query.

select ID, FIRSTNAME, LASTNAME from people order by LASTNAME, FIRSTNAME

robert

 -Original Message-
 From: Søren Blidorf [mailto:[EMAIL PROTECTED]
 Sent: Monday, March 10, 2003 1:17 PM
 To: [EMAIL PROTECTED]
 Subject: Sort a collection in alphabetic order



 Hi.
 I need to sort my collection people in alphabetic order by lastname,
 firstname.
 Can anybody help me?

 I guess I should do it in the Action and not when displayed in jsp page.



 Collection people = new ArrayList();

 while( rs.next() ) {
 PeopleBean pb = new PeopleBean();
 pb.setId(rs.getInt(ID));
 pb.setFirstname( rs.getString( FIRSTNAME ));
 pb.setLastname( rs.getString( LASTNAME ));
 }

 people.add( pb );


 Søren Blidorf





 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



SV: Sort a collection in alphabetic order

2003-03-10 Thread Søren Blidorf
It is not possible.

The select is in a while (rs.next()) {} depending on another value. (Not
easy to explain!!)

I am a ware of normal SQL order by

-Oprindelig meddelelse-
Fra: Dave Newton [mailto:[EMAIL PROTECTED] 
Sendt: 10. marts 2003 19:20
Til: Struts Users Mailing List
Emne: Re: Sort a collection in alphabetic order

On Mon, 2003-03-10 at 13:16, Søren Blidorf wrote:
 I need to sort my collection people in alphabetic order by lastname,
 firstname. Can anybody help me?

Most algorithm books will give you more information than you want on
sorting.

Why not just do it in the query and let the db do it?

Dave



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Sort a collection in alphabetic order

2003-03-10 Thread nash e. foster


You could have your PeopleBean implement Comparable, which is pretty 
easy, and then use TreeSet to create a sorted set using your compareTo 
method.

-nash

On Monday, March 10, 2003, at 01:16  PM, Søren Blidorf wrote:

Hi.
I need to sort my collection people in alphabetic order by lastname,
firstname.
Can anybody help me?
I guess I should do it in the Action and not when displayed in jsp 
page.



Collection people = new ArrayList();

while( rs.next() ) {
PeopleBean pb = new PeopleBean();
pb.setId(rs.getInt(ID));
pb.setFirstname( rs.getString( FIRSTNAME ));
pb.setLastname( rs.getString( LASTNAME ));
}
people.add( pb );

Søren Blidorf





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


***
This message is intended only for the use of the intended recipient and
may contain information that is PRIVILEGED and/or CONFIDENTIAL.  If you
are not the intended recipient, you are hereby notified that any use,
dissemination, disclosure or copying of this communication is strictly
prohibited.  If you have received this communication in error, please
destroy all copies of this message and its attachments and notify us
immediately.
***
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Sort a collection in alphabetic order

2003-03-10 Thread Dave Patton
I concur with Nash.  Use a Comparator Object for this. Itis in the
java.util package.

Dave Patton
 


On Mon, 2003-03-10 at 10:27, nash e. foster wrote:

 You could have your PeopleBean implement Comparable, which is pretty 
 easy, and then use TreeSet to create a sorted set using your compareTo 
 method.
 
 -nash
 
 On Monday, March 10, 2003, at 01:16  PM, Søren Blidorf wrote:
 
 
  Hi.
  I need to sort my collection people in alphabetic order by lastname,
  firstname.
  Can anybody help me?
 
  I guess I should do it in the Action and not when displayed in jsp 
  page.
 
 
 
  Collection people = new ArrayList();
 
  while( rs.next() ) {
  PeopleBean pb = new PeopleBean();
  pb.setId(rs.getInt(ID));
  pb.setFirstname( rs.getString( FIRSTNAME ));
  pb.setLastname( rs.getString( LASTNAME ));
  }
 
  people.add( pb );
 
 
  Søren Blidorf
 
 
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 ***
 This message is intended only for the use of the intended recipient and
 may contain information that is PRIVILEGED and/or CONFIDENTIAL.  If you
 are not the intended recipient, you are hereby notified that any use,
 dissemination, disclosure or copying of this communication is strictly
 prohibited.  If you have received this communication in error, please
 destroy all copies of this message and its attachments and notify us
 immediately.
 ***
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



_
David H. Patton
[EMAIL PROTECTED]
(202) 276-8998 - pcs

-BEGIN PGP PUBLIC KEY BLOCK- 

Version: PGPfreeware 7.0.3 for non-commercial use http://www.pgp.com 

mQENBDui6osBCADP9OqVftQ2qxZz2fsxEf6GT6V2Fu0c2iIIMeWGyc5Pwl+xXe2w 
3wx2pmNkLy3Zjp2/5q4nhvJd/GVn5gRR9OVTKgAz4o+xcOcAVIbgz3xFICbLozKa 
2aZOUDtOu0TuYGhI9iIeGuPjnMjsS38EfZQ2DWwd+p5UW6wnsSuG7xniUT372v8w 
YrtUwnKQwjRUGUlZoX1zwvJj50xEzipyyHosMuzjoHme+d+MEECRhAK81p0487kl 
X0UMXBehnsFK1mjbtQgfy2fdk0KT4NxKSD5s8ojoSdJ7R5CMwvh1UM4v2aAEqKvE 
CYaCWrAfZ7+TQGHXu75ejJz1iIuUno1fVsgLABEBAAG0IkRhdmUgUGF0dG9uIDxk 
cGF0dG9uQG52ZW50dXJlLmNvbT6JAS4EEAECABgFAjui6osICwMJCAcCAQoCGQEF 
GwMACgkQ5ZDkPqeKwH9Xswf/aP2WGiAU+HFxV136uKW5oDtZtSvm0YuW69Ra 
A2dPKFPp6E7v+w2c7yEV4+ZkVxbfk+VOh3p1MpXR367nQl9C+jMAD7MvPU6/KI+T 
5WDzzKEGsyxOI+GYeGRKO0ZAYITG9HxevvKa1GMHBwRYNr2Qv62ckkHTy5rdmzZe 
PFM/am8B9maH5gKg6oIqzJwfmvb+ll8DRbhfI25trLqzggifrFcZHkOwTVGLNfdM 
cPWK/Yu4dOLAKCow06q0G/tDmXNkcyx12R6Z4Y/cQ5Qyvt1WP+eQAM/HBJI8rR9c 
cxS80pEorJIx4a7x9EsiwmB8milqBrXqHN2GRe/PnZSM9czBK7kBDQQ7ouqNAQgA 
sWO4lchFwK6leJClCpdaCjL4oUGjiZorW+XG2YKtQW6a+oYlplcHFkMSibkTN6Jc 
RdPEkarRvJ7sj+UgsUfkj4//EtqARuHTXhnMlsjqISTXlS2l61fQFg1d0iwvinyV 
sq6lVDtrr7UBe2b5TOuoRe13CzGWyhNQafV1gMcpBx9KxNi24UowJiT+cJpnxMCu 
+DNElC2AmG7phPagSFL8F4f++dGL2l8kAkxCSCl3Kr+8HUlFmOwwZ1PGSSM83pM/ 
NNZKDAdGUiBRKqC32oOhKacxb6cf4ta1kZ6GDZcqVo+5qlz4OtUKbRLtW5Y8tiFc 
PwkDePX/F1490V3YWgHVzwARAQABiQEiBBgBAgAMBQI7ouqNBRsMAAoJEOWQ 
5D6nisB/8xsIAJLNUQC8SOQF5txBrO22W7uAJ9xU9RK66Pyf9a+KjdNf4rE6vK4n 
vhbSGmtoPB4bzOQ9RKpo8ihBQp1cY9mLnwuJDKSuzpkaOK5pd+bifwY20tweULR6 
4rtU8uLL1H0eom2IBjSXhf4n8DEdyrGKKHYNO/GRLx/UHHcLEFvz+4buHrCPoiBP 
JwjS/Ifg5xc3nTJnZmG2HzapoRwgXxGitbNTArUZWkqHYLygA1/ilmnFs8POj/s+ 
TD4wSuDlrwE2CE2O8XbRuRVPryzn8mXXdZ1pSwrrvZjRU5rnDRAOqhHZQQbudVd3 
XvnDDBDoURSqwDqnwOkoOSTC95aj+vy5WW0= 
=/zoc 

-END PGP PUBLIC KEY BLOCK-


Re: Sort a collection in alphabetic order

2003-03-10 Thread Vic Cekvenich
http://edhill.its.uiowa.edu/display-0.8/

Robert Taylor wrote:
Do it in the query.

select ID, FIRSTNAME, LASTNAME from people order by LASTNAME, FIRSTNAME

robert


-Original Message-
From: Søren Blidorf [mailto:[EMAIL PROTECTED]
Sent: Monday, March 10, 2003 1:17 PM
To: [EMAIL PROTECTED]
Subject: Sort a collection in alphabetic order


Hi.
I need to sort my collection people in alphabetic order by lastname,
firstname.
Can anybody help me?
I guess I should do it in the Action and not when displayed in jsp page.



Collection people = new ArrayList();

while( rs.next() ) {
PeopleBean pb = new PeopleBean();
pb.setId(rs.getInt(ID));
pb.setFirstname( rs.getString( FIRSTNAME ));
pb.setLastname( rs.getString( LASTNAME ));
}
people.add( pb );

Søren Blidorf





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Sort a collection in alphabetic order

2003-03-10 Thread David Haynes
Since you are in a while(rs.next()) context, why not sort on insertion?
Just pop your results into a Vector (or other collection) in sort-order.
Depending upon the number of elements expected, you could speed the
insertion using a number of methods. If your lists are relatively small,
it may be efficient to just start at the beginning of the vector and
walk through it looking for the insertion point.

-david-

-Original Message-
From: Søren Blidorf [mailto:[EMAIL PROTECTED] 
Sent: March 10, 2003 1:25 PM
To: 'Struts Users Mailing List'
Subject: SV: Sort a collection in alphabetic order

It is not possible.

The select is in a while (rs.next()) {} depending on another value. (Not
easy to explain!!)

I am a ware of normal SQL order by

-Oprindelig meddelelse-
Fra: Dave Newton [mailto:[EMAIL PROTECTED] 
Sendt: 10. marts 2003 19:20
Til: Struts Users Mailing List
Emne: Re: Sort a collection in alphabetic order

On Mon, 2003-03-10 at 13:16, Søren Blidorf wrote:
 I need to sort my collection people in alphabetic order by lastname,
 firstname. Can anybody help me?

Most algorithm books will give you more information than you want on
sorting.

Why not just do it in the query and let the db do it?

Dave



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Sort a collection in alphabetic order

2003-03-10 Thread apachep2
Comparable is always a good idea. But I am curious to know why you are
unable to do a re-SELECT statement?

-Original Message-
From: David Haynes [mailto:[EMAIL PROTECTED] 
Sent: March 10, 2003 3:49 PM
To: 'Struts Users Mailing List'
Subject: RE: Sort a collection in alphabetic order

Since you are in a while(rs.next()) context, why not sort on insertion?
Just pop your results into a Vector (or other collection) in sort-order.
Depending upon the number of elements expected, you could speed the
insertion using a number of methods. If your lists are relatively small,
it may be efficient to just start at the beginning of the vector and
walk through it looking for the insertion point.

-david-

-Original Message-
From: Søren Blidorf [mailto:[EMAIL PROTECTED] 
Sent: March 10, 2003 1:25 PM
To: 'Struts Users Mailing List'
Subject: SV: Sort a collection in alphabetic order

It is not possible.

The select is in a while (rs.next()) {} depending on another value. (Not
easy to explain!!)

I am a ware of normal SQL order by

-Oprindelig meddelelse-
Fra: Dave Newton [mailto:[EMAIL PROTECTED] 
Sendt: 10. marts 2003 19:20
Til: Struts Users Mailing List
Emne: Re: Sort a collection in alphabetic order

On Mon, 2003-03-10 at 13:16, Søren Blidorf wrote:
 I need to sort my collection people in alphabetic order by lastname,
 firstname. Can anybody help me?

Most algorithm books will give you more information than you want on
sorting.

Why not just do it in the query and let the db do it?

Dave



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Sort a collection in alphabetic order

2003-03-10 Thread David Haynes
Although I don't know anything about Soren's specific problem, I have
had times where the database is protected by a bean and the process of
having a new data access method on the bean is simply too complex to be
believed (i.e. you have about a gazillion review processes to go
through). In these cases, I have found it sometimes useful to take the
data as it comes and massage it locally.

-david-

-Original Message-
From: apachep2 [mailto:[EMAIL PROTECTED] 
Sent: March 10, 2003 3:54 PM
To: 'Struts Users Mailing List'
Subject: RE: Sort a collection in alphabetic order

Comparable is always a good idea. But I am curious to know why you are
unable to do a re-SELECT statement?

-Original Message-
From: David Haynes [mailto:[EMAIL PROTECTED] 
Sent: March 10, 2003 3:49 PM
To: 'Struts Users Mailing List'
Subject: RE: Sort a collection in alphabetic order

Since you are in a while(rs.next()) context, why not sort on insertion?
Just pop your results into a Vector (or other collection) in sort-order.
Depending upon the number of elements expected, you could speed the
insertion using a number of methods. If your lists are relatively small,
it may be efficient to just start at the beginning of the vector and
walk through it looking for the insertion point.

-david-

-Original Message-
From: Søren Blidorf [mailto:[EMAIL PROTECTED] 
Sent: March 10, 2003 1:25 PM
To: 'Struts Users Mailing List'
Subject: SV: Sort a collection in alphabetic order

It is not possible.

The select is in a while (rs.next()) {} depending on another value. (Not
easy to explain!!)

I am a ware of normal SQL order by

-Oprindelig meddelelse-
Fra: Dave Newton [mailto:[EMAIL PROTECTED] 
Sendt: 10. marts 2003 19:20
Til: Struts Users Mailing List
Emne: Re: Sort a collection in alphabetic order

On Mon, 2003-03-10 at 13:16, Søren Blidorf wrote:
 I need to sort my collection people in alphabetic order by lastname,
 firstname. Can anybody help me?

Most algorithm books will give you more information than you want on
sorting.

Why not just do it in the query and let the db do it?

Dave



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Sort a collection in alphabetic order

2003-03-10 Thread Damm, Gary
Keep in mind Strings implement Comparable.  So if the lastName field of your 
PeopleBean is a String it makes the local sorting that much easier (no need to make 
changes to the PeopleBean).  You can just do the comparisons based on the lastName 
field (or any other field that implements Comparable).

-Original Message-
From: David Haynes [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 10, 2003 12:59 PM
To: 'Struts Users Mailing List'
Subject: RE: Sort a collection in alphabetic order

Although I don't know anything about Soren's specific problem, I have
had times where the database is protected by a bean and the process of
having a new data access method on the bean is simply too complex to be
believed (i.e. you have about a gazillion review processes to go
through). In these cases, I have found it sometimes useful to take the
data as it comes and massage it locally.

-david-

-Original Message-
From: apachep2 [mailto:[EMAIL PROTECTED] 
Sent: March 10, 2003 3:54 PM
To: 'Struts Users Mailing List'
Subject: RE: Sort a collection in alphabetic order

Comparable is always a good idea. But I am curious to know why you are
unable to do a re-SELECT statement?

-Original Message-
From: David Haynes [mailto:[EMAIL PROTECTED] 
Sent: March 10, 2003 3:49 PM
To: 'Struts Users Mailing List'
Subject: RE: Sort a collection in alphabetic order

Since you are in a while(rs.next()) context, why not sort on insertion?
Just pop your results into a Vector (or other collection) in sort-order.
Depending upon the number of elements expected, you could speed the
insertion using a number of methods. If your lists are relatively small,
it may be efficient to just start at the beginning of the vector and
walk through it looking for the insertion point.

-david-

-Original Message-
From: Søren Blidorf [mailto:[EMAIL PROTECTED] 
Sent: March 10, 2003 1:25 PM
To: 'Struts Users Mailing List'
Subject: SV: Sort a collection in alphabetic order

It is not possible.

The select is in a while (rs.next()) {} depending on another value. (Not
easy to explain!!)

I am a ware of normal SQL order by

-Oprindelig meddelelse-
Fra: Dave Newton [mailto:[EMAIL PROTECTED] 
Sendt: 10. marts 2003 19:20
Til: Struts Users Mailing List
Emne: Re: Sort a collection in alphabetic order

On Mon, 2003-03-10 at 13:16, Søren Blidorf wrote:
 I need to sort my collection people in alphabetic order by lastname,
 firstname. Can anybody help me?

Most algorithm books will give you more information than you want on
sorting.

Why not just do it in the query and let the db do it?

Dave



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



SV: Sort a collection in alphabetic order

2003-03-10 Thread Søren Blidorf
Sorry, but I can't get it to work.

Does any body have a simple example I can look at?

Soren

-Oprindelig meddelelse-
Fra: nash e. foster [mailto:[EMAIL PROTECTED] 
Sendt: 10. marts 2003 19:27
Til: Struts Users Mailing List
Emne: Re: Sort a collection in alphabetic order 



You could have your PeopleBean implement Comparable, which is pretty 
easy, and then use TreeSet to create a sorted set using your compareTo 
method.

-nash

On Monday, March 10, 2003, at 01:16  PM, Søren Blidorf wrote:


 Hi.
 I need to sort my collection people in alphabetic order by lastname,
 firstname.
 Can anybody help me?

 I guess I should do it in the Action and not when displayed in jsp 
 page.



 Collection people = new ArrayList();

 while( rs.next() ) {
 PeopleBean pb = new PeopleBean();
 pb.setId(rs.getInt(ID));
 pb.setFirstname( rs.getString( FIRSTNAME ));
 pb.setLastname( rs.getString( LASTNAME ));
 }

 people.add( pb );


 Søren Blidorf





 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


***
This message is intended only for the use of the intended recipient and
may contain information that is PRIVILEGED and/or CONFIDENTIAL.  If you
are not the intended recipient, you are hereby notified that any use,
dissemination, disclosure or copying of this communication is strictly
prohibited.  If you have received this communication in error, please
destroy all copies of this message and its attachments and notify us
immediately.
***


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Sort a collection in alphabetic order

2003-03-10 Thread Yan, Charlene
Try this:

import org.apache.commons.beanutils.BeanComparator;

Collections.sort(people, new BeanComparator(lastname));

Charlene

-Original Message-
From: Søren Blidorf [mailto:[EMAIL PROTECTED]
Sent: Monday, March 10, 2003 4:33 PM
To: 'Struts Users Mailing List'
Subject: SV: Sort a collection in alphabetic order 


Sorry, but I can't get it to work.

Does any body have a simple example I can look at?

Soren

-Oprindelig meddelelse-
Fra: nash e. foster [mailto:[EMAIL PROTECTED] 
Sendt: 10. marts 2003 19:27
Til: Struts Users Mailing List
Emne: Re: Sort a collection in alphabetic order 



You could have your PeopleBean implement Comparable, which is pretty 
easy, and then use TreeSet to create a sorted set using your compareTo 
method.

-nash

On Monday, March 10, 2003, at 01:16  PM, Søren Blidorf wrote:


 Hi.
 I need to sort my collection people in alphabetic order by lastname,
 firstname.
 Can anybody help me?

 I guess I should do it in the Action and not when displayed in jsp 
 page.



 Collection people = new ArrayList();

 while( rs.next() ) {
 PeopleBean pb = new PeopleBean();
 pb.setId(rs.getInt(ID));
 pb.setFirstname( rs.getString( FIRSTNAME ));
 pb.setLastname( rs.getString( LASTNAME ));
 }

 people.add( pb );


 Søren Blidorf





 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


***
This message is intended only for the use of the intended recipient and
may contain information that is PRIVILEGED and/or CONFIDENTIAL.  If you
are not the intended recipient, you are hereby notified that any use,
dissemination, disclosure or copying of this communication is strictly
prohibited.  If you have received this communication in error, please
destroy all copies of this message and its attachments and notify us
immediately.
***


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



SV: Sort a collection in alphabetic order

2003-03-10 Thread Søren Blidorf
Thanks a million.

You just made my day.

Soren

-Oprindelig meddelelse-
Fra: Yan, Charlene [mailto:[EMAIL PROTECTED] 
Sendt: 10. marts 2003 23:12
Til: Struts Users Mailing List
Emne: RE: Sort a collection in alphabetic order 

Try this:

import org.apache.commons.beanutils.BeanComparator;

Collections.sort(people, new BeanComparator(lastname));

Charlene

-Original Message-
From: Søren Blidorf [mailto:[EMAIL PROTECTED]
Sent: Monday, March 10, 2003 4:33 PM
To: 'Struts Users Mailing List'
Subject: SV: Sort a collection in alphabetic order 


Sorry, but I can't get it to work.

Does any body have a simple example I can look at?

Soren

-Oprindelig meddelelse-
Fra: nash e. foster [mailto:[EMAIL PROTECTED] 
Sendt: 10. marts 2003 19:27
Til: Struts Users Mailing List
Emne: Re: Sort a collection in alphabetic order 



You could have your PeopleBean implement Comparable, which is pretty 
easy, and then use TreeSet to create a sorted set using your compareTo 
method.

-nash

On Monday, March 10, 2003, at 01:16  PM, Søren Blidorf wrote:


 Hi.
 I need to sort my collection people in alphabetic order by lastname,
 firstname.
 Can anybody help me?

 I guess I should do it in the Action and not when displayed in jsp 
 page.



 Collection people = new ArrayList();

 while( rs.next() ) {
 PeopleBean pb = new PeopleBean();
 pb.setId(rs.getInt(ID));
 pb.setFirstname( rs.getString( FIRSTNAME ));
 pb.setLastname( rs.getString( LASTNAME ));
 }

 people.add( pb );


 Søren Blidorf





 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


***
This message is intended only for the use of the intended recipient and
may contain information that is PRIVILEGED and/or CONFIDENTIAL.  If you
are not the intended recipient, you are hereby notified that any use,
dissemination, disclosure or copying of this communication is strictly
prohibited.  If you have received this communication in error, please
destroy all copies of this message and its attachments and notify us
immediately.
***


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]