You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by "Alexander Lamb (dev)" <al...@mac.com> on 2007/12/10 17:53:54 UTC
More than one ordering for in memory sort
Hello List,
I am sorting a to-many list in memory:
List<RegistryEnrollment> re = getEnrollments();
Ordering ordering = new Ordering("year", true);
ordering.orderList(re);
return re;
But I would like to add a second sort criteria (month after year)
I found there were expressions, but no example for formatting them.
Thanks,
Alex
--
Alexander Lamb
alamb@mac.com
Re: More than one ordering for in memory sort
Posted by Kevin Menard <km...@servprise.com>.
On 12/10/07 12:31 PM, "Andrus Adamchik" <an...@objectstyle.org> wrote:
> You should use a static Ordering method that takes a list of orderings:
>
> Ordering.orderList(List<?> objects, List<Comparator<Object>>
> orderings)
>
> Andrus
Ahh, yes. I forgot about that one. I was actually just playing with it
last week.
--
Kevin
Re: More than one ordering for in memory sort
Posted by Andrus Adamchik <an...@objectstyle.org>.
You should use a static Ordering method that takes a list of orderings:
Ordering.orderList(List<?> objects, List<Comparator<Object>>
orderings)
Andrus
On Dec 10, 2007, at 7:21 PM, Kevin Menard wrote:
> I'm not sure how you'd go about it this way, but you can add any
> number of
> Orderings to a SelectQuery. If the objects are already cached, you
> shouldn't really see a performance hit. I've not tried it myself,
> however.
>
> --
> Kevin
>
> On 12/10/07 11:53 AM, "Alexander Lamb (dev)" <al...@mac.com> wrote:
>
>> Hello List,
>>
>> I am sorting a to-many list in memory:
>>
>> List<RegistryEnrollment> re = getEnrollments();
>> Ordering ordering = new Ordering("year", true);
>> ordering.orderList(re);
>> return re;
>>
>> But I would like to add a second sort criteria (month after year)
>>
>> I found there were expressions, but no example for formatting them.
>>
>> Thanks,
>>
>> Alex
>>
>> --
>> Alexander Lamb
>> alamb@mac.com
>
>
Re: More than one ordering for in memory sort
Posted by Kevin Menard <km...@servprise.com>.
I'm not sure how you'd go about it this way, but you can add any number of
Orderings to a SelectQuery. If the objects are already cached, you
shouldn't really see a performance hit. I've not tried it myself, however.
--
Kevin
On 12/10/07 11:53 AM, "Alexander Lamb (dev)" <al...@mac.com> wrote:
> Hello List,
>
> I am sorting a to-many list in memory:
>
> List<RegistryEnrollment> re = getEnrollments();
> Ordering ordering = new Ordering("year", true);
> ordering.orderList(re);
> return re;
>
> But I would like to add a second sort criteria (month after year)
>
> I found there were expressions, but no example for formatting them.
>
> Thanks,
>
> Alex
>
> --
> Alexander Lamb
> alamb@mac.com