Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!apple!jdevoto From: jdevoto@Apple.COM (Jeanne A. E. DeVoto) Newsgroups: comp.sys.mac.hypercard Subject: Re: Sorting by multiple keys Message-ID: <26528@apple.Apple.COM> Date: 28 Feb 89 20:37:34 GMT References: <2053@tank.uchicago.edu> Distribution: usa Organization: Apple Computer Inc, Cupertino, CA Lines: 24 In article <2053@tank.uchicago.edu> ben@rover.bsd.uchicago.edu writes: >I want to sort my cards by to "keys" for instance: >if I have a field date and a field name. >I want to sort my cards by date and all events happening on the same day >to be sorted by name. HyperTalk's sort algorithm is of the type called "stable". That is, a sort will not change the order of cards that have the same sort key. What this means is that you can accomplish what you want by using multiple sorts. In this case, you would first sort by the "Name" field, then sort by the "Date" field. The second sort leaves the name order of cards that have the same date untouched. The general rule is to sort by least significant key first. The HyperTalk for this example might look like this: on sortMyStack put "Now sorting stack..." sort by background field "Name" sort dateTime by background field "Date" hide message box end sortMyStack jeanne a. e. devoto jdevoto@apple.com