home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / mac / hypercar / 3363 < prev    next >
Encoding:
Internet Message Format  |  1992-09-04  |  2.0 KB

  1. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!rphroy!cmsa.gmr.com!KGODDEN
  2. From: KGODDEN@cmsa.gmr.com
  3. Newsgroups: comp.sys.mac.hypercard
  4. Subject: Re: HC 2.1 "sort" command
  5. Message-ID: <168587D0B.KGODDEN@cmsa.gmr.com>
  6. Date: 4 Sep 92 13:53:28 GMT
  7. References: <1992Sep3.224521.5605@kronos.arc.nasa.gov>
  8. Sender: news@rphroy.ph.gmr.com
  9. Organization: GM Research Labs
  10. Lines: 42
  11. Nntp-Posting-Host: cmsa.gmr.com
  12.  
  13. In article <1992Sep3.224521.5605@kronos.arc.nasa.gov>
  14. joshr@kronos.arc.nasa.gov (Joshua Rabinowitz-Summer-91) writes:
  15.  
  16. >
  17. >Hey, macnetters:
  18. >
  19. >I have a simple question I hope you can help me to answer.
  20. >
  21. >Suppose I have a script with the following line:
  22. >
  23. >put "name 2" & return & "name 5" & return & "name 21" & return &
  24. >   "name 1" & return into abc
  25. >
  26. >and I want to sort the lines in that var by the number which is the last word
  27. >of each line.
  28. >
  29. <stuff deleted>
  30.  
  31. You're right.  You can't sort this as is.  You COULD do it if you were sorting
  32. CARDS (as opposed to the contents of a variable) where that info appeared in
  33. some field.  This is a bewildering incompatibility between the card sort
  34. and the variable sort, and CERTAINLY ought to be fixed in the next update
  35. of HC (are you listening Claris?--check out the &key parameter in the
  36. Common Lisp sort, that's what  you need in HC).
  37.  
  38. So what to do?....The solution I used (with help from others on the net)
  39. in a similar situation was to transform each line of the variable such that
  40. sort would give the correct order I wanted, and then transform each line of
  41. the result back again.  For you, (IF your example is literally representative)
  42. this could be done by reversing the words of each line, sorting, and then
  43. reversing each line back again.  I.e. instead of sorting
  44. name 2
  45. name 5
  46. name 21
  47. name 1
  48. you would transform each into e.g. 2 name, 5 name, etc.  Then do your sort
  49. and then put the nums back to the end of each line.
  50. It's an ugly hack, but it'll stem the dike until Claris does it the Right Way.
  51. -Kurt
  52. --------------------
  53. "I distrust a research person who is always obviously busy on a task."
  54. -Robert A. Frosch, VP, GM Research
  55.