Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!apple!dan From: dan@Apple.COM (Dan Allen) Newsgroups: comp.sys.mac.hypercard Subject: Re: Sorting Efficiently Message-ID: <27208@apple.Apple.COM> Date: 13 Mar 89 18:52:16 GMT References: <670@maths.tcd.ie> Organization: Apple Computer Inc, Cupertino, CA Lines: 26 In article <670@maths.tcd.ie> mlloyd@maths.tcd.ie (Michael Lloyd) writes: >My question is, as this sort takes long enough to be VERY irritating (it needs >doing very often), would there be any better place to create new cards? I >might (wildly) guess that cards created at the START of the stack might speed >up the process - this could happen if the cards are treated in order when >sorts go into action. If you want to always keep a stack in sorted order, sort in once and then do the following whenever you want to insert a new card: do a binary search and then do a New Card. The New Card will be placed after the current card. Adding cards to the beginning of a stack or end of a stack should not matter that much. Cards are actually kept in a somewhat arbitrary order on disk. (Compact stack will actually reorganize them to allow scanning through a stack to be as fast as possible.) A different problem is growing an existing card. Let's say that you frequently add text to the first card in a stack. The card will no longer fit where it was, so it will probably be moved to the end of the stack on disk, and the file will be grown. The card's former location will be empty and will be used the next time something can fit in the hole that was left. Dan Allen Apple Computer