[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#17099: Does sort have a bug?
From: |
Prem Thoppae |
Subject: |
bug#17099: Does sort have a bug? |
Date: |
Wed, 26 Mar 2014 13:42:09 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130809 Thunderbird/17.0.8 |
(1) I am using the following version of sort,
$ sort --version
sort (GNU coreutils) 5.97
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software. You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and Paul Eggert.
----------------------------------------------------------------------------------------------------------
(2) When I sort the following,
../include/CcMsgFxStrm.h
../include/CDesEncrypt.h
../include/CEncrypt.h
include/CFixFX_Config.h
include/CFixFX_Handler.h
include/CFixFX_Server.h
../include/CFxBaseMsg.h
include/CFXBookManager.h
I am expecting for all the ../include's to bunch up before or after all
the include's. But, the above is already in sorted order, according to
sort! Something doesn't seem right. Is there a bug?
----------------------------------------------------------------------------------------------------------
(3) If I write a C++ program as follows,
# include <cstdio>
# include <vector>
# include <iostream>
using namespace std;
int
main ()
{
vector<string> lines;
char buf[1024];
for (int i = 0; fgets (buf, sizeof buf, stdin); i++)
lines.push_back (buf);
for (int i = 0, sz = lines.size (); i < sz; i++)
for (int j = i + 1; j < sz; j++)
if (lines[j] < lines[i])
{
string t = lines[i];
lines[i] = lines[j];
lines[j] = t;
}
for (int i = 0, sz = lines.size (); i < sz; i++)
cout << lines[i];
}
For the above input, I get the following output,
../include/CDesEncrypt.h
../include/CEncrypt.h
../include/CFxBaseMsg.h
../include/CcMsgFxStrm.h
include/CFXBookManager.h
include/CFixFX_Config.h
include/CFixFX_Handler.h
include/CFixFX_Server.h
----------------------------------------------------------------------------------------------------------
(4) Thanks for looking into this and sending me a reply.
- bug#17099: Does sort have a bug?,
Prem Thoppae <=