textutils-2.1, sort v2.0.14 question
Jason Smigiel <[email protected]> Thu, 26 Sep 2002 17:16:53 -0500
| Newsgroups | gmane.comp.gnu.textutils.bugs |
|---|---|
| Message-ID | <[email protected]> |
I've seen what I consider to be weird sort behavior with sort v2.0.14. (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