• 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
Sort array speed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sort array speed


  • Subject: Sort array speed
  • From: Conor Dearden <email@hidden>
  • Date: Thu, 10 Nov 2005 15:53:51 +0100

I noticed that sorting an array with a hint is faster than a regular sort,
even though the hint is nil. For example:  (collectionItems is a
NSMutableArray).


    NSArray *sortedArray;
    sortedArray = [collectionItems sortedArrayUsingFunction:fastSort
context:theContext hint:nil];
    [collectionItems replaceObjectsInRange:NSMakeRange(0, [collectionItems
count]) withObjectsFromArray:sortedArray];

    is faster than:

     [collectionItems sortUsingFunction:fastSort context:theContext];


So the question is (since the behaviour make no logical sense to me) do I
simply always use the hinted version and forget about the mutableArray
method? What is the point of the sortUsingFunction: when the other is faster
and does the same job in all cases? What is it I am not seeing, will using
hint: get me later on?

Conor Dearden
http://www.bruji.com/


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: problem with custom field editor (NSTextView)
  • Next by Date: Core Data bug? (storing a "special" char sequence)
  • Previous by thread: problem with custom field editor (NSTextView)
  • Next by thread: Core Data bug? (storing a "special" char sequence)
  • Index(es):
    • Date
    • Thread