• 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: NSArray.sortedArrayUsingComparator(OrderedAscending)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArray.sortedArrayUsingComparator(OrderedAscending)


  • Subject: Re: NSArray.sortedArrayUsingComparator(OrderedAscending)
  • From: Art Isbell <email@hidden>
  • Date: Tue, 1 Jun 2004 15:20:59 -1000

On Jun 1, 2004, at 2:37 PM, Nathan Dumar wrote:

If I do this:

users = users.sortedArrayUsingComparator(OrderedAscending);

what key is used to sort? (users is an NSArray of custom type UserClass)

How can I tell it to use user.name or user.ssn or ... ?

Or am I going about this all wrong? (I'm trying to recreate some of the basic functionality of a WODisplayGroup, after deciding not to use it, for reasons mentioned in an earlier post.)

You can do this by creating a NSComparator subclass that will sort by whatever key you desire and do whatever processing may be necessary. "OrderedAscending" is an int so can't be a sortedArrayUsingComparator() argument, but an instance of your NSComparator subclass can be.


However, if you're sorting by one or more of the object's attributes where no processing is required, it's far easier to sort an array of EO's using EOSortOrdering.sortedArrayUsingKeyOrderArray().

Aloha,
Art
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >NSArray.sortedArrayUsingComparator(OrderedAscending) (From: Nathan Dumar <email@hidden>)

  • Prev by Date: Off Topic (Slightly) Missing Groups in Documentation Window xCode 1.2
  • Next by Date: Re: NSArray.sortedArrayUsingComparator(OrderedAscending)
  • Previous by thread: NSArray.sortedArrayUsingComparator(OrderedAscending)
  • Next by thread: Re: NSArray.sortedArrayUsingComparator(OrderedAscending)
  • Index(es):
    • Date
    • Thread