[comp.sys.mac.hypercard] Sorting part of a stack?

dwiggins@atsun.a-t.com (Don Dwiggins) (10/11/90)

I have a stack with 3 backgrounds, with several cards per.  I'd like to sort
just the cards within a given background.  Is there an easy way to do this?
The only approach that's occurred to me so far is to copy the cards to a
"scratch stack", sort that, and replace the cards with the result.

While I'm asking, is there an archive of HC goodies that's accessible to
those of us in the "net boonies", i.e. without FTP access?

--
Don Dwiggins				"If you think training is expensive,
Ashton-Tate, Inc.			 try ignorance"
dwiggins@ashtate.a-t.com		 -- Derek Bok, Harvard U.

jdevoto@Apple.COM (Jeanne A. E. DeVoto) (10/11/90)

In article <DWIGGINS.90Oct10172006@atsun.a-t.com> dwiggins@atsun.a-t.com
(Don Dwiggins) inquires:
>I have a stack with 3 backgrounds, with several cards per.  I'd like to sort
>just the cards within a given background.  Is there an easy way to do this?

Often the simplest approach when sorting is to use a function called by
sort. For instance,

  on sortMeUp theBackground
    sort this stack by justBackground(theBackground)
  end sortMeUp

  function justBackground myBackground
    if the short name of this background is not myBackground then
      return "z"
    else return field "Name"
  end justBackground

The above will sort cards of the selected background by the background
field "Name", and sort cards of all other backgrounds to the end of the
stack (leaving their relative ordering unchanged). Of course, much more
complicated functions can be used.
-- 
========= jeanne a. e. devoto ========================================
 jdevoto@apple.com     |  You may not distribute this article under a
 jdevoto@well.sf.ca.us |  compilation copyright without my permission.
______________________________________________________________________
 Apple Computer and I are not authorized      |        CI$: 72411,165
 to speak for each other.                     |

gandalf@apple.com (Martin Gannholm) (10/12/90)

In article <DWIGGINS.90Oct10172006@atsun.a-t.com> dwiggins@atsun.a-t.com 
(Don Dwiggins) writes:
> I have a stack with 3 backgrounds, with several cards per.  I'd like to 
sort
> just the cards within a given background.

Since someone else already posted a solution for HyperCard 1.x, I won't 
repeat that.

When you upgrade to HyperCard 2.0, you won't have to use the funky scripts 
to get the desired result. You can simply say "sort cards of this bg" or 
"sort cards of bkgnd foo". The cards of the specified bkgnd will be sorted 
in relation to each other, but all the other cards will retain their same 
position in the stack. This will be a different result from the one 
obtained by the funky-script approach if the cards of a bkgnd are 
interspersed with cards from another one.
  You can also say "sort marked cards", just sorting cards that have the 
new 2.0 property "marked" set.

Martin Gannholm
HyperCard 2.0 Engineer
Apple Computer

Exclaimer!!!   I typed this myself = I speak for myself...