Re: ERXSortOrderings
Re: ERXSortOrderings
- Subject: Re: ERXSortOrderings
- From: Hugi Thordarson <email@hidden>
- Date: Fri, 17 Jun 2016 10:02:25 +0000
Hi Luiz,
If you’re sorting during a DB fetch, you should be able to set a collation on your table/column (although if you’re using Oracle, there’s some discussion on this issue here):
http://lists.apple.com/archives/webobjects-dev/2010/Jan/msg00458.html
If you’re sorting in memory, you can use the workaround created here:
http://lists.apple.com/archives/webobjects-dev/2012/Jul/msg00418.html
If you’re using java 8, you can use Collections sorting rather than of EOSortOrdering. It’s a little more verbose but allows you to control whether nulls should appear first or last (and if you’re chaining comparators you can use the thenComparing method on comparator).
NSArray<Pet> pets = fetchSomePets();
pets.sort( Comparator.comparing( Pet::name, Comparator.nullsLast( Comparator.naturalOrder() ) );
Hope this helps.
Cheers,
- hugi
> On 16. jún. 2016, at 16:08, Luiz Alfredo Carrara Bertusso <email@hidden> wrote:
>
> Hello.
> I've used the method sorted of ERXSortOrderings to sort a list according to some rules.
> The list I've sorted may have null values sometimes and I'd like these null values coming at the end of the list. Is there an option to do that?
>
> Thanks.
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >ERXSortOrderings (From: Luiz Alfredo Carrara Bertusso <email@hidden>) |