Newsgroups: comp.sys.mac.hypercard Path: utzoo!lsuc!dave From: dave@lsuc.on.ca (David Sherman|LSUC|Toronto) Subject: Re: How do you sort within a field? Message-ID: <1990May7.233204.20167@lsuc.on.ca> Organization: Law Society of Upper Canada, Toronto References: <3082@phred.UUCP> Date: Mon, 7 May 90 23:32:04 GMT In article <3082@phred.UUCP> johnd@phred.UUCP (John Daynes) writes: >Anyway, I have a card with a scrolling field on it. The field has >a long list of items in it that I would like to sort alphabetically. >It appears that the SORT command just wants to sort CARDS by >something in a field. I just want to sort the contents of ONE FIELD. If speed is important, use an XFCN. If speed isn't important, you can write a sort routine in HyperTalk quite easily. Namir & Shammas' *Mastering HyperTalk* book has a nice implementation of quicksort which is quite short to type in, and performs about as fast as anything you'll get in HyperTalk. For speed, by the way, any repeated access to a field should be done with a variable instead. If necessary, copy the field to a global variable and have the sort routine operate on the variable, then copy it back when done. Performance will be an order of magnitude better than when operating directly on the field. Same goes for any case in which you're gradually adding to, or processing, the information in a field. David Sherman (Anyone remember the movie "Sorting Out Sorting"? It's still shown in CS classes, I believe. I programmed that movie, many years ago. I never *really* understood quicksort until I watched my algorithm running graphically:-) -- Moderator, mail.yiddish { uunet!attcan att utzoo }!lsuc!dave dave@lsuc.on.ca