johnd@phred.UUCP (John Daynes) (05/04/90)
I'm stuck and my only reference book is The Complete Hypercard Handbook. Not much help, I'm afraid. 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. Any suggestions? Sorry if this is a pretty basic question--I use Hypercard a lot, but don't need to use fields much.
gbc@cahaba.med.unc.edu (Geoff Crooks) (05/05/90)
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. > >Any suggestions? There is an XFCN called SortLines that will do just what you want... It sorts the contents of a field ascending or decending by the first character of each line of the field... it works well.. I used it in my VideoStak - be glad to mail you a copy if you can't find it elsewhere - I think (if memory serves) it came as part of a collection of XCMD/XFCNs (PD/SW) put out by Dartmouth. Hope this helps. Geoff. * Geoff Crooks "She told me to make myself comfortable * * Dept of Psychology so I pulled down my pants and sat in the * * Univ. of No. Carolina pudding..." Emo Phillips * * gbc@med.unc.edu *
dave@lsuc.on.ca (David Sherman|LSUC|Toronto) (05/08/90)
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