You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Henri Yandell <ba...@generationjava.com> on 2002/09/10 20:43:05 UTC

[collections] CollectionsUtils.isSorted

I wrote an isSorted and a sortedDirection pair of methods the other day.
Nothing fancy, they just tell you if a List is currently in a sorted
order, and/or the direction in which it is sorted.

This of interest to a class in Collections?

Hen


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [collections] CollectionsUtils.isSorted

Posted by Stephen Colebourne <sc...@btopenworld.com>.
I think I'm +1 if its just one method - getSortOrder() returns ASCENDING,
DESCENDING or NOT_SORTED.

Stephen

----- Original Message -----
From: "Henri Yandell" <ba...@generationjava.com>
To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
Sent: Friday, September 13, 2002 8:54 PM
Subject: Re: [collections] CollectionsUtils.isSorted


>
> I had an algorithm at work in which I had N values from a database and I
> have to do something if they follow a trend, ie) they all go in the same
> direction.
>
> I decided to solve it with a generic 'is this List sorted' method.
>
> Other use cases... I could see something doing isSorted before sorting as
> an attempt at improving speed usually. ie) If someone clicks on a header
> and sorts one way, then does a reverse sort, the code might do isSorted to
> decide that all it had to do was reverse the list.
>
> I admit it's not got the high usability of Collections.sort :)
>
> Hen
>
> On Fri, 13 Sep 2002, Stephen Colebourne wrote:
>
> > Do you have a use case for them? I struggling to see the need ATM.
> >
> > Stephen
> >
> > ----- Original Message -----
> > From: "Henri Yandell" <ba...@generationjava.com>
> > > I wrote an isSorted and a sortedDirection pair of methods the other
day.
> > > Nothing fancy, they just tell you if a List is currently in a sorted
> > > order, and/or the direction in which it is sorted.
> > >
> > > This of interest to a class in Collections?
> > >
> > > Hen
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [collections] CollectionsUtils.isSorted

Posted by Henri Yandell <ba...@generationjava.com>.
I had an algorithm at work in which I had N values from a database and I
have to do something if they follow a trend, ie) they all go in the same
direction.

I decided to solve it with a generic 'is this List sorted' method.

Other use cases... I could see something doing isSorted before sorting as
an attempt at improving speed usually. ie) If someone clicks on a header
and sorts one way, then does a reverse sort, the code might do isSorted to
decide that all it had to do was reverse the list.

I admit it's not got the high usability of Collections.sort :)

Hen

On Fri, 13 Sep 2002, Stephen Colebourne wrote:

> Do you have a use case for them? I struggling to see the need ATM.
>
> Stephen
>
> ----- Original Message -----
> From: "Henri Yandell" <ba...@generationjava.com>
> > I wrote an isSorted and a sortedDirection pair of methods the other day.
> > Nothing fancy, they just tell you if a List is currently in a sorted
> > order, and/or the direction in which it is sorted.
> >
> > This of interest to a class in Collections?
> >
> > Hen
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [collections] CollectionsUtils.isSorted

Posted by Stephen Colebourne <sc...@btopenworld.com>.
Do you have a use case for them? I struggling to see the need ATM.

Stephen

----- Original Message -----
From: "Henri Yandell" <ba...@generationjava.com>
> I wrote an isSorted and a sortedDirection pair of methods the other day.
> Nothing fancy, they just tell you if a List is currently in a sorted
> order, and/or the direction in which it is sorted.
>
> This of interest to a class in Collections?
>
> Hen
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>