Sort array speed
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