bug-textutils
[Top][All Lists]
Advanced

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

Re: textutils-2.1, sort v2.0.14 question


From: Bob Proulx
Subject: Re: textutils-2.1, sort v2.0.14 question
Date: Thu Sep 26 19:37:02 2002
User-agent: Mutt/1.4i

Jason Smigiel <address@hidden> [2002-09-26 17:16:53 -0500]:
> I've seen what I consider to be weird sort behavior with sort v2.0.14.

Thanks for the report.  You have hit a common ailment.  So often that
a standard reply has been prepared.  Please check out this section on
sort.

  
http://www.gnu.org/software/fileutils/doc/faq/#Sort%20does%20not%20sorting%20in%20normal%20order!

I am sure that is your problem.  Check out the output of the 'locale'
command and you will certainly see something non-standard there.
Standard being defined to be either "C" or "POSIX".

  locale

  unset LANG

If that is not your problem then please send another followup.

Also, hidden in the info snippet you provided look for LC_COLLATE.
And also read the man page for strcoll().

Bob

Please follow up to the list and not to be me personally unless it is
personal.

> (Weird, in that it does not agree with how I interpret the sort manual,
> but maybe I am mis-interpreting the sort manual.)
> 
> 1) Given the input 'garbled':
> a
> g g h i
> i first
> i three
> a c d
> c e g
> i three x
> i three m
> c b
> i second
> i three a
> ithreewords
> i three words
> i
> ifirst
> isecond
> 
> 2) Sort produces this output, with the command `sort <garbled`:
> a
> a c d
> c b
> c e g
> g g h i
> i
> ifirst
> i first
> isecond
> i second
> i three
> i three a
> i three m
> ithreewords
> i three words
> i three x
> 
> 3) But, the output that I expect can be produced with this command
> `sort -k 1,1 <garbled`:
> a
> a c d
> c b
> c e g
> g g h i
> i
> i first
> i second
> i three
> i three a
> i three m
> i three words
> i three x
> ifirst
> isecond
> ithreewords
> 
> 
> The manual states:
> 
> >     A pair of lines is compared as follows: if any key fields have been
> > specified, `sort' compares each pair of fields, in the order specified on
> > the command line, according to the associated ordering options, until a
> > difference is found or no fields are left.  Unless otherwise specified,
> > all comparisons use the character collating sequence specified by the
> > `LC_COLLATE' locale.
> > 
> >    If any of the global options `bdfgiMnr' are given but no key fields
> > are specified, `sort' compares the entire lines according to the global
> > options.
> > 
> >    Finally, as a last resort when all keys compare equal (or if no
> > ordering options were specified at all), `sort' compares the entire
> > lines.  The last resort comparison honors the `--reverse' (`-r') global
> > option.  The `--stable' (`-s') option disables this last-resort
> > comparison so that lines in which all fields compare equal are left in
> > their original relative order.  If no fields or global options are
> > specified, `--stable' (`-s') has no effect
> 
> As I understand it, in example '2)' above, no keys are specified, and
> I would expect the output that example '3)' produces.
> 
> Is there some reasoning as to why example '2)' produces the output it
> does that I am missing?
> 
> (Note: These results are from the tarball textutils-2.1.tar.gz, and that
> I compiled and ran on RedHat 7.2, if that's important. )
> 
> 
> Thank-you for any help,
> Jason
> 
> 
> _______________________________________________
> Bug-textutils mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-textutils
> 




reply via email to

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