home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / perl / 6962 < prev    next >
Encoding:
Text File  |  1992-11-12  |  1.0 KB  |  34 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!ames!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!ira.uka.de!fauern!fauna!cip.informatik.uni-erlangen.de!mnrausch
  3. From: mnrausch@cip.informatik.uni-erlangen.de (Martin Rausche)
  4. Subject: sorting problem
  5. Message-ID: <BxM5w2.Iyr@immd4.informatik.uni-erlangen.de>
  6. Sender: news@immd4.informatik.uni-erlangen.de
  7. Organization: Student Pool, CSD, University of Erlangen, Germany
  8. Date: Thu, 12 Nov 1992 17:28:50 GMT
  9. Keywords: sort
  10. Lines: 22
  11.  
  12. I need a fast sorting routine for the following problem:
  13. I have a database and the entries look like this:
  14. keyword;author;title;owner
  15. My solution:
  16.  
  17. sub byname
  18. {
  19.         @ah=split(/;/,$a);
  20.         @be=split(/;/,$b);
  21.         shift(@ah);
  22.         shift(@be);
  23.         $ah=join(";",@ah);
  24.         $be=join(";",@be);
  25.         $ah cmp $be;
  26. }
  27.  
  28. @data=sort byname @data;
  29.  
  30. This is a very slow procedure, but how can I speed it up?
  31.  
  32. Thanks in advance. Martin.
  33. (mnrausch@cip.informatik.uni-erlangen.de)
  34.