I've never seen it documented though perceived performance would indicate this is indeed the case

Generally, implementation details about caching behaviors falls isn't something that gets formally documented. It's not part of the API contract, and can change some from release to release.

That said, Robert is right that NSSortDescriptor does significant caching throughout the sorting. It assumes the results of valueForKey are stable for the duration of the sorting operation. If your custom comparison function is based on valueForKey, NSSortDescriptor will do a much better job than -sortedArrayUsingFunction. That said, NSSortDescriptor is really only happy with keys and keypaths, and overriding its comparison method will disable the caching.

What kind of calculations are involved when sorting? I ask because . 5s for sorting 4000 objects seems *incredibly* slow

What Mike said.

- Ben

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to