Bug in sort!?

Tim Behrendsen <[email protected]>
Newsgroups gmane.comp.gnu.textutils.bugs
Message-ID <Pine.LNX.4.44.0207212036340.2660-100000@www>
Hello,

I can't believe it, but the sort command appears to have a sorting bug!

I'm running version 2.0.14 on RedHat 7.3.

If I put these 3 lines in a file 'foo'...

packages/YCC Form.pm
packages/YCC/Form HistoryForm.pm
packages/YCC/Form PropertyForm.pm

and then type 'sort foo', I get...

packages/YCC/Form HistoryForm.pm
packages/YCC Form.pm
packages/YCC/Form PropertyForm.pm

How can this be under any circumstances? No matter how you sort it, the
middle line should come out at the end or the beginning! Just to make
sure I wasn't crazy, I wrote a perl program to make sure I wasn't just
missing a funny character or something...

my @list;
my $ln;
while ($ln = <>) {
    push(@list, $ln);
}
print join('', sort @list);

The Perl program on the exact file I'm using for this test is...

packages/YCC Form.pm
packages/YCC/Form HistoryForm.pm
packages/YCC/Form PropertyForm.pm

... which is what I would expect. I'm cutting and pasting all this, so
this is the exact input and output.

I'd love to hear a logical explanation for this! :)

Thanks,

Tim Behrendsen
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.