• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: A custom way to sort EOs by key ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A custom way to sort EOs by key ?


  • Subject: Re: A custom way to sort EOs by key ?
  • From: Lachlan Deck <email@hidden>
  • Date: Sat, 12 May 2007 10:44:44 +1000

Hi Fabrice,

On 11/05/2007, at 5:55 PM, Fabrice Pipart wrote:

On May 10, 2007, at 11:19 PM, Matthew W. Taylor wrote:
It sounds like what you want to do is perform "Natural" sort ordering to the results.
sortedArray = unsortedArray.sortedArrayUsingComparator(new EOCustomObjectNaturalOrderComparator("nameOfKeyToSortBy"));


// EOCustomObjectNaturalOrderComparator.java

That's absolutely what I was looking for :-)
I had just missed the NSArray.sortedArrayUsingComparator method :(
And it's far more obvious how to subclass a NSComparator than a NSSelector ;-)


The only drawback compared to EOSortOrdering.sortedArrayUsingKeyOrderArray is that I cannot do ordering for several keys : ORDER BY name, otherKey ...

You wouldn't want to subclass EOSortOrdering anyway, but either
- have your 'Screen' entity implement EOSortOrdering.Comparison, or
- create YourNaturalSortOrdering extending EOSortOrdering.ComparisonSupport and, at application launch, for every entity that you need in-memory natural sort ordering:


public Application extends ... {
private static final EOSortOrdering.ComparisonSupport naturalOrdering = new YourNaturalSortOrdering();


foreach natural sorting entity:
EOSortOrdering.ComparisonSupport.setSupportForClass ( naturalOrdering, <entity>.class );
}


or follow the NSComparator approach as others have suggested.

with regards,
--

Lachlan Deck



_______________________________________________
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: 
 >Re: A custom way to sort EOs by key ? (From: Robert Walker <email@hidden>)
 >Re: A custom way to sort EOs by key ? (From: "Matthew W. Taylor" <email@hidden>)
 >Re: A custom way to sort EOs by key ? (From: Fabrice Pipart <email@hidden>)

  • Prev by Date: Re: Frontbase boolean and EO...
  • Next by Date: [ANN] DMSelenium framework release
  • Previous by thread: Re: A custom way to sort EOs by key ?
  • Next by thread: Re: A custom way to sort EOs by key ?
  • Index(es):
    • Date
    • Thread