[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sort "in"compatibilities with xpg4...

From: Jim Meyering
Subject: Re: Sort "in"compatibilities with xpg4...
Date: Fri, 21 Mar 2003 16:20:44 +0100

Thank you for the report.
However, I believe that the current behavior conforms to the POSIX spec.

The description of sort's -k option here


includes this paragraph:

  When there are multiple key fields, later keys shall be compared only
  after all earlier keys compare equal. Except when the -u option is
  specified, lines that otherwise compare equal shall be ordered as if none
  of the options -d, -f, -i, -n, or -k were present (but with -r still in
  effect, if it was specified) and with all bytes in the lines significant
  to the comparison. The order in which lines that still compare equal
  are written is unspecified.

Which I read as saying

  without -u, when sort determines that two lines compare equal (e.g.,
  based on your -k2,2 option), it must sort them as if the entire
  line were the key (e.g., taking into account the leading 1,2,3
  on the lines in your test1 input file).

I'll add something to that effect in the documentation.

Hendrik Visage <address@hidden> wrote:
> Hi there, below is a "issue" I would believe that sort should
> handle "correctly" as per the xpg4 versions, not the SVR4 version
> of sort (Or is that POSIX correct") to take -k 1,1 as the whole line.
> Is there a way to force sort to handle -k 1,1 the same way as -k 2,2??
> Below hermwas is a Solaris 2.6 machine, while meklon is a
> Linux machine with Textutils 2.1.
> Greetz
> Hendrik
> hermwas% /usr/xpg4/bin/sort  -k 1,1 -c  test
> hermwas% /usr/bin/sort  -k 1,1 -c  test
> sort: disorder: robert anderson
> hermwas% /usr/xpg4/bin/sort  -k 1,1 -c  test
> hermwas% /usr/xpg4/bin/sort  -k 2,2 -c  test1
> hermwas% cat test
> robert upton
> robert anderson
> robert botha
> hermwas% cat test1
> 1 robert upton
> 2 robert anderson
> 3 robert botha
> meklon% sort -k 1,1 -c  test
> sort: test:2: disorder: robert anderson
> meklon% sort -k 2,2 -c  test1
> meklon% cat test
> robert upton
> robert anderson
> robert botha
> meklon% cat test1
> 1 robert upton
> 2 robert anderson
> 3 robert botha

reply via email to

[Prev in Thread] Current Thread [Next in Thread]