home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 6129 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: pub.news.uk.psi.net!usenet
  2. From: Matthew Towler <Matthew.Towler@unicam.co.uk>
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Sorting a list
  5. Date: 22 Mar 1996 12:29:51 GMT
  6. Organization: PSINet UK Public Usenet Site
  7. Message-ID: <4iu6g0$rsc@pub.news.uk.psi.net>
  8. NNTP-Posting-Host: 193.122.53.13
  9.  
  10. mojaveg@ridgecrest.ca.us (Everett M. Greene) asks:
  11.  
  12. > How does one alphabetize the pointers?
  13.  
  14. You don't really, you alphabetise the strings using the pointers.
  15. Essentially you sort an array of pointers to the strings, as then
  16. when you wish to swap the positions of two strings you only need 
  17. to move the pointers, rather than the whole strings.  This also
  18. has the advantage that were you to sort an array of strings, all
  19. would have to be of the same length, or have the same amount of
  20. storage allocated.  While the pointers approach means the strings
  21. can be totally different lengths; it even allows you to sort a list
  22. of string constants, without copying them to a variable string 
  23. array, thus saving memory and time.
  24.  
  25. To evaluate whether or not one string is higher in the alphabet you
  26. pass the pointers to strcmp().
  27.