• 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: NSMutableArray sorting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableArray sorting


  • Subject: Re: NSMutableArray sorting
  • From: Ben Trumbull <email@hidden>
  • Date: Mon, 22 Dec 2008 01:09:37 -0800

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@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSMutableArray sorting
      • From: "Adam R. Maxwell" <email@hidden>
    • Re: NSMutableArray sorting
      • From: Scott Ribe <email@hidden>
  • Prev by Date: NSToolbarItem identifier?
  • Next by Date: re: Managed Object won't dealloc even after Hit with Kitchen Sink
  • Previous by thread: Re: NSToolbarItem identifier?
  • Next by thread: Re: NSMutableArray sorting
  • Index(es):
    • Date
    • Thread