You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Søren Blidorf <so...@nolas.dk> on 2003/12/18 18:20:03 UTC

beanutils.BeanComparator

Hi.

I am using the org.apache.commons.beanutils.BeanComparator;

I am doing the following:

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

How can I sort by lastname and then by firstname?

If I do this:

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

It's only sorted by firstname.

Please help and best regards.

Soren



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


SV: beanutils.BeanComparator

Posted by Søren Blidorf <so...@nolas.dk>.
Thanks a mill both.

It works great.

Soren

-----Oprindelig meddelelse-----
Fra: Henri Yandell [mailto:bayard@generationjava.com] 
Sendt: 18. december 2003 20:37
Til: Jakarta Commons Users List; epugh@upstate.com
Emne: RE: beanutils.BeanComparator


It's in Commons Collections by the way, and does exactly what Eric says.
ReverseComparator is also worthy of the same area of use.

Hen

On Thu, 18 Dec 2003, Eric Pugh wrote:

> Check out a ComparatorChain...
> ComparatorChain chain = new ComparatorChain();
> chain.add(new BeanComparator("lastname"));
> chain.add(new BeanComparator("firstname"));
> Collections.sort(people, chain);
>
> Works like a champ!  I use it all the time for sorting tables in
webapps..
> just click the header, handin the sort and off you go...
>
> ERic
>
> > -----Original Message-----
> > From: Søren Blidorf [mailto:soren@nolas.dk]
> > Sent: Thursday, December 18, 2003 6:20 PM
> > To: commons-user@jakarta.apache.org
> > Subject: beanutils.BeanComparator
> >
> >
> > Hi.
> >
> > I am using the org.apache.commons.beanutils.BeanComparator;
> >
> > I am doing the following:
> >
> > Collections.sort(people, new BeanComparator("lastname"));
> >
> > How can I sort by lastname and then by firstname?
> >
> > If I do this:
> >
> > Collections.sort(people, new BeanComparator("lastname"));
> > Collections.sort(people, new BeanComparator("firstname"));
> >
> > It's only sorted by firstname.
> >
> > Please help and best regards.
> >
> > Soren
> >
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
commons-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


RE: beanutils.BeanComparator

Posted by Henri Yandell <ba...@generationjava.com>.
It's in Commons Collections by the way, and does exactly what Eric says.
ReverseComparator is also worthy of the same area of use.

Hen

On Thu, 18 Dec 2003, Eric Pugh wrote:

> Check out a ComparatorChain...
> ComparatorChain chain = new ComparatorChain();
> chain.add(new BeanComparator("lastname"));
> chain.add(new BeanComparator("firstname"));
> Collections.sort(people, chain);
>
> Works like a champ!  I use it all the time for sorting tables in webapps..
> just click the header, handin the sort and off you go...
>
> ERic
>
> > -----Original Message-----
> > From: S�ren Blidorf [mailto:soren@nolas.dk]
> > Sent: Thursday, December 18, 2003 6:20 PM
> > To: commons-user@jakarta.apache.org
> > Subject: beanutils.BeanComparator
> >
> >
> > Hi.
> >
> > I am using the org.apache.commons.beanutils.BeanComparator;
> >
> > I am doing the following:
> >
> > Collections.sort(people, new BeanComparator("lastname"));
> >
> > How can I sort by lastname and then by firstname?
> >
> > If I do this:
> >
> > Collections.sort(people, new BeanComparator("lastname"));
> > Collections.sort(people, new BeanComparator("firstname"));
> >
> > It's only sorted by firstname.
> >
> > Please help and best regards.
> >
> > Soren
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


RE: beanutils.BeanComparator

Posted by Eric Pugh <ep...@upstate.com>.
Check out a ComparatorChain...
ComparatorChain chain = new ComparatorChain();
chain.add(new BeanComparator("lastname"));
chain.add(new BeanComparator("firstname"));
Collections.sort(people, chain);

Works like a champ!  I use it all the time for sorting tables in webapps..
just click the header, handin the sort and off you go...

ERic

> -----Original Message-----
> From: Søren Blidorf [mailto:soren@nolas.dk]
> Sent: Thursday, December 18, 2003 6:20 PM
> To: commons-user@jakarta.apache.org
> Subject: beanutils.BeanComparator
>
>
> Hi.
>
> I am using the org.apache.commons.beanutils.BeanComparator;
>
> I am doing the following:
>
> Collections.sort(people, new BeanComparator("lastname"));
>
> How can I sort by lastname and then by firstname?
>
> If I do this:
>
> Collections.sort(people, new BeanComparator("lastname"));
> Collections.sort(people, new BeanComparator("firstname"));
>
> It's only sorted by firstname.
>
> Please help and best regards.
>
> Soren
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org