Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: stroyan@fc.hp.com (Mike Stroyan)
Subject: Re: Sort keys buggy?
Date: 1996/02/29	[thread overview]
Message-ID: <4h32aj$kaf@fcnews.fc.hp.com> (raw)
In-Reply-To: 1996Feb28.190715.9327@llyene.jpl.nasa.gov

Michael P Urban (urban@cobra.jpl.nasa.gov) wrote:
|The output of the command,
|   sort -k 1 -k 2n
|with an input file like:
...
|b 2
...
|b 10
|b 20
...
|does not produce the result I would expect; the second column is
|sorted lexicographically instead of numerically.  This occurs on HP-UX
|9.01, HP-UX 10, and DEC OSF1 V3.2.

  The trick is that the first key, "-k 1", is specifying a range from
the start of the first field to the end of line.  All of the lines are
unique in that key, so the second key never gets a chance to influence
the sort.

  You can get the effect you were looking for by using a first key that
is only the first field-

sort -k 1,1 -k 2n

--
Mike Stroyan, mike_stroyan@fc.hp.com



      reply	other threads:[~1996-02-29  5:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-02-28  5:00 Sort keys buggy? Michael P Urban
1996-02-29  5:00 ` Mike Stroyan [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox