Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!microsoft!uw-beaver!tektronix!tekmdp!bronze!grahamr From: grahamr@bronze.UUCP (Graham Ross) Newsgroups: net.unix-wizards Subject: Re: /bin/sort bug Message-ID: <721@bronze.UUCP> Date: Thu, 1-Sep-83 13:19:29 EDT Article-I.D.: bronze.721 Posted: Thu Sep 1 13:19:29 1983 Date-Received: Fri, 2-Sep-83 14:48:36 EDT Lines: 14 /bin/sort's quick sort algorithm is unstable (in the sense of Knuth, ACP, Vol. 3, p. 4). To achieve stability, do the following: cat -n output This prepends an identifying number to each line in the input, which stays with it until the sorting is done. The +0n key in the sort gives a numeric comparison on this first field. Remember to bump the column numbers in you original sort flags. The "\t"s in the sed command probably should be real tabs (I forget). If you don't have cat's -n option (another UCB monstrosity, I think) you can easily write a separate program to do it. -Graham Ross teklabs!tekmdp!grahamr