• 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: Sorting Time Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting Time Question


  • Subject: Re: Sorting Time Question
  • From: ryan <email@hidden>
  • Date: Wed, 26 Mar 2003 19:45:01 -0800

On 3/26/03 7:30 PM, "Francisco Tolmasky" <email@hidden> wrote:

> Ok, if I have a self sorting array, when an object changes it must be
> resorted. Should I just call sortUsingFunction: or whatever, or is it
> worth it to implement a function that removes this item and reinserts
> it itself, possibly using a binary search to find where it belongs.

Best sorting algorithm: O( n log n )
Best binary search algorithm: O( log n )

From that, its obvious that using the re-insertion is the faster solution.

If your list is really small, and will stay small, its probably easier to
just call sortUsingFunction:.

Hope this helps.

-ryan



>
> So basicall, if this is the original:
>
> 1
> 2
> 3
>
> and 2 is changed to 5, then should I resort, OR do this
>
> remove 2, leaving:
>
> 1
> 3
>
> insert 5:
>
> 1
> 3
> 5
>
>
> Francisco Tolmasky
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Sorting Time Question (From: Francisco Tolmasky <email@hidden>)

  • Prev by Date: Executing short AppleScript command sets
  • Next by Date: Re: [OT] Macho Love
  • Previous by thread: Sorting Time Question
  • Next by thread: Re: Sorting Time Question
  • Index(es):
    • Date
    • Thread