emacs-bug-tracker
[Top][All Lists]
Advanced

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

[debbugs-tracker] bug#17099: closed (Does sort have a bug?)


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#17099: closed (Does sort have a bug?)
Date: Wed, 26 Mar 2014 16:29:02 +0000

Your message dated Wed, 26 Mar 2014 10:28:19 -0600
with message-id <address@hidden>
and subject line Re: bug#17099: Does sort have a bug?
has caused the debbugs.gnu.org bug report #17099,
regarding Does sort have a bug?
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
17099: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17099
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 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.





--- End Message ---
--- Begin Message --- Subject: Re: bug#17099: Does sort have a bug? Date: Wed, 26 Mar 2014 10:28:19 -0600 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0
tag 17099 notabug
thanks

On 03/26/2014 07:42 AM, Prem Thoppae wrote:

>     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?

Not a bug, but a FAQ:

https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#Sort-does-not-sort-in-normal-order_0021

You probably sorted in the en_US.UTF-8 locale (or related), where that
locale is defined to do dictionary collation where punctuation is
ignored.  Since '../' is punctuation, it is ignored and does not affect
the sort.  If you want every byte to affect the sort, choose a different
locale, as in:

LC_ALL=C sort ...

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---

reply via email to

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