Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!mcvax!diku!olamb!kimcm From: kimcm@olamb.UUCP (Kim Chr. Madsen) Newsgroups: comp.unix.questions,comp.sources.wanted Subject: Re: Multiple Field Sorts in UNIX(tm) Message-ID: <305@olamb.UUCP> Date: Thu, 23-Jul-87 06:07:18 EDT Article-I.D.: olamb.305 Posted: Thu Jul 23 06:07:18 1987 Date-Received: Sat, 25-Jul-87 11:58:34 EDT References: <2459@whuts.UUCP> Organization: AmbraSoft A/S (Denmark) Lines: 19 Summary: sort CAN do it in one pass Xref: mnetor comp.unix.questions:3319 comp.sources.wanted:1703 In article <2459@whuts.UUCP>, tes@whuts.UUCP (STERKEL) writes: > > An inefficient implementation of this has been: > cat file | sort on field3 | sort on field2 | sort on field1 > sorted > > BUT, this only for sorts that are "bubble" and/or "shell". > Using Sort(1) "scrambles" the previous sorts on each pass, > leaving me with no easy way to use sort(1) to do multiple > field sorts. You can do it in one pass through standard sort(1), by specifying the fields in order. sort +1 -2 +3 -4 +2 -3 datafile should sort "datafile" by primary key field 2 secondary key field 4 tertiary key field 3 and ignoring cointents of field 1. Kim Chr. Madsen.