home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / perl / 7605 < prev    next >
Encoding:
Text File  |  1992-12-23  |  926 b   |  24 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!gatech!rpi!think.com!ames!sun-barr!sh.wide!wnoc-tyo-news!sranha!sranhd!sran230!utashiro
  3. From: utashiro@sran230.sra.co.jp (Kazumasa Utashiro)
  4. Subject: Re: Looking for a "numerical/alpha" sort routine.
  5. References: <1992Dec23.193120.25893@pool.info.sunyit.edu>
  6. Organization: Software Research Associates, Inc., Japan
  7. Date: Thu, 24 Dec 1992 03:21:24 GMT
  8. Message-ID: <Bzqunp.9rD@sran230.sra.co.jp>
  9. Lines: 13
  10.  
  11. In article <1992Dec23.193120.25893@pool.info.sunyit.edu>
  12.     buck@pool.info.sunyit.edu (Jesse Buckley) writes:
  13. >> Does anyone have a sort/compare routine that will work for numerical
  14. >> alpha data?  For example, if I have 1, 2, 3a, 3b, 3c, I want them sorted
  15. >> that way.  Right now the <=> compare ignored the letters after the
  16. >> numbers.  Thanks.
  17.  
  18. Next line works for your example.
  19.  
  20. @s = sort { $a <=> $b || $a cmp $b } ('3c', '1', '3a', '2', '3b');
  21. print "@s\n";
  22.  
  23. --utashiro
  24.