Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!ncar!oddjob!uwvax!umn-d-ub!umn-cs!dg!indermau From: indermau@dg (Kurt Indermaur) Newsgroups: comp.unix.questions Subject: stable sort in unix tools? Message-ID: <5456@umn-cs.cs.umn.edu> Date: 18 May 88 02:06:17 GMT Sender: news@umn-cs.cs.umn.edu Reply-To: indermau@dg.cs.umn.edu.UUCP (Kurt Indermaur) Distribution: na Organization: University of Minnesota, Minneapolis, Computer Science Department. Lines: 29 Posted: Tue May 17 21:06:17 1988 I'm stuck with a little sorting problem... not big enough to write my own sorting routine, but annoying nevertheless. I have a file with lines like: 1237 A2 text comments 1357 A3 more text 1644 A1 blah blah blah 1718 A1 still more (sorted by the number in the first column) that I would like to get sorted by the classification in the second column (A1, A2, A3...), but keeping the numbers in order within each classification. The above list, for instance, would end up: 1644 A1 blah blah blah 1718 A1 still more 1237 A2 text comments 1357 A3 more text I need a stable sort, in other words, and the standard (4.3 bsd) UNIX sort doesn't seem to provide that. Is there a way around this using UNIX tools? Is there another way? Any help (including programs, if necessary) would be appreciated. Please respond by e-mail... I don't often get the chance to read this group. Thanks, Kurt Indermaur (indermau@dg.cs.umn.edu)