Re: NSMutableArray sorting
Re: NSMutableArray sorting
- Subject: Re: NSMutableArray sorting
- From: "Michael Ash" <email@hidden>
- Date: Sun, 21 Dec 2008 22:32:30 -0500
On Sun, Dec 21, 2008 at 10:08 PM, John Nairn <email@hidden> wrote:
> Yes, I think the key is that the expensive calculation is done only once for
> each object rather than every time a comparison needs to be made. After the
> caching, my approach does all the searching in one method using swaps of
> integers. I don't know how much faster (in any) that would be compared to
> internal NSArray sort code. It sorts about 4000 names (on a slow PowerBoook
> G4) in half second or less. Since a common use of sorting is for data in
> columns of a table and clicking twice just reverses the list, I added a
> custom option to check if the list is sorted but backwards and then just
> swap elements in place if it is.
What kind of calculations are involved when sorting? I ask because .5s
for sorting 4000 objects seems *incredibly* slow. A quick Python test
program I whipped up here can sort about four *hundred* thousand
objects in half a second. Now my Mac Pro is just *slightly* faster
than a Powerbook... but on the other hand, Python is not exactly known
for being swift.
Could be that your object comparisons or precalculations are just
inherently slow. But in that case, they're going to utterly swamp any
extra overhead coming from the ObjC runtime being used in NSArray's
sort function.
Mike
_______________________________________________
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