home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / question / 14667 < prev    next >
Encoding:
Text File  |  1992-12-14  |  1.3 KB  |  30 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!psinntp!jpradley!jpr
  3. From: jpr@jpradley.jpr.com (Jean-Pierre Radley)
  4. Subject: Re: a sort question
  5. Organization: Unix in NYC
  6. Date: Mon, 14 Dec 1992 03:49:54 GMT
  7. Message-ID: <1992Dec14.034954.5104@jpradley.jpr.com>
  8. References: <4564@bimacs.BITNET> <1992Dec11.225522.23590@trebor.uucp>
  9. Lines: 19
  10.  
  11. In article <1992Dec11.225522.23590@trebor.uucp> root@trebor.uucp (Bob Stockler) writes:
  12. >yedidya@bimacs.BITNET (Yedidya Israel) writes:
  13. >
  14. >>I want to sort a file according to two keys i.e. lines that equal
  15. >>first key are compared upon their second key (sort +3-3.10 +3.12-3.14
  16. >>in my case). My question concerns lines that equals in both keys how
  17. >>do I guarantee that their order will be kept as in input file ???
  18.  
  19. The manual says that if all the keys furnished have compared equal, lines
  20. are then ordered with every byte significant, so you do have to take
  21. additional measures to preserve the input order in Y. Israel's case.
  22.  
  23. >One way (I think) to _guarantee_ it would be to pipe the input through "nl"
  24. >and use the input line numbers appropriately as an additional sort key.
  25.  
  26. I'm surprised you didn't furnish an awk script to reverse the effects of
  27. nl (though sed would be more straightforward in this case).
  28. -- 
  29. Jean-Pierre Radley   Unix in NYC   jpr@jpr.com   jpradley!jpr   CIS: 72160.1341
  30.