Re: NSArray.sortedArrayUsingComparator(OrderedAscending)
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.