From unknown Fri Sep 05 11:02:25 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#9562 <9562@debbugs.gnu.org> To: bug#9562 <9562@debbugs.gnu.org> Subject: Status: unexpected sort behaviour Reply-To: bug#9562 <9562@debbugs.gnu.org> Date: Fri, 05 Sep 2025 18:02:25 +0000 retitle 9562 unexpected sort behaviour reassign 9562 coreutils submitter 9562 vijay krishna severity 9562 normal tag 9562 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 20 12:22:50 2011 Received: (at submit) by debbugs.gnu.org; 20 Sep 2011 16:22:50 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R635t-0006Rt-K6 for submit@debbugs.gnu.org; Tue, 20 Sep 2011 12:22:50 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R5z5F-0000P5-GL for submit@debbugs.gnu.org; Tue, 20 Sep 2011 08:05:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R5z09-0001yR-Gs for submit@debbugs.gnu.org; Tue, 20 Sep 2011 08:00:46 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:47932) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R5z09-0001yJ-F3 for submit@debbugs.gnu.org; Tue, 20 Sep 2011 08:00:37 -0400 Received: from eggs.gnu.org ([140.186.70.92]:45860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R5z03-0001yQ-LE for bug-coreutils@gnu.org; Tue, 20 Sep 2011 08:00:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R5yzy-0001uv-8y for bug-coreutils@gnu.org; Tue, 20 Sep 2011 08:00:31 -0400 Received: from mail-iy0-f195.google.com ([209.85.210.195]:64988) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R5yzy-0001uc-0i for bug-coreutils@gnu.org; Tue, 20 Sep 2011 08:00:26 -0400 Received: by iaeo4 with SMTP id o4so155160iae.6 for ; Tue, 20 Sep 2011 05:00:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; bh=oyUo4Cx6JxaJDHvoeUEMXselE+0yvHqpZrYQVQJSjWw=; b=RMA6PwmvCymgJjLDYhRXcpV0wluhOW287MppDBWyD0sMgptbdvn1yLsjkTrNTOCdzn d9btUlj1KjbmwzNa2JTTR+FN6pXnuwjjuAQ/PRRYXhConmq6IA9LnclxYefmxHxhjByR fYSkMgwztcHt/h/ceFNrAp0mhI5AwPWzcdayc= Received: by 10.231.8.32 with SMTP id f32mr1250491ibf.65.1316519531277; Tue, 20 Sep 2011 04:52:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.38.9 with HTTP; Tue, 20 Sep 2011 04:51:51 -0700 (PDT) From: vijay krishna Date: Tue, 20 Sep 2011 04:51:51 -0700 Message-ID: Subject: unexpected sort behaviour To: bug-coreutils Content-Type: multipart/alternative; boundary=0015176f14ea006dbd04ad5e1781 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Tue, 20 Sep 2011 12:22:47 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) --0015176f14ea006dbd04ad5e1781 Content-Type: text/plain; charset=ISO-8859-1 Hello Team, May I please know the reason for the following behaviour of the sort command... ------------------ 0 $ sort -k 2 bug2_file2 512 b1 512 b101 0 $ sort bug2_file1 b101 512 b1 512 0 $ sort -k 1 bug2_file1 b101 512 b1 512 ------------------ The output is same with options '-s', '-g', '-n', '-d' (used one at a time) also. ------------------ 0 $ 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 . There is NO WARRANTY, to the extent permitted by law. Written by Mike Haertel and Paul Eggert. Regards, Krishna --0015176f14ea006dbd04ad5e1781 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hello Team,
=A0
=A0 May I please know the reason for the following behaviour of the so= rt command...
=A0
------------------
0 $ sort -k 2 bug2_file2
512 b1
512 b101

0 $ sort bug2_file1
b101 512
b1 512

0 $ sort -k 1 bug2_file1
b101 512
b1 512
----------------= --
=A0
=A0 The output is same with options=A0 '-s', '-g', = 9;-n', '-d' (used one at a time) also.
=A0
=A0
=A0
------------------
0 $ sort --version
sort (GNU coreutils) 5.97
Copyright (C) 2006 = Free Software Foundation, Inc.
This is free software.=A0 You may redistr= ibute 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.
=A0
=A0
Regards,
Krishna
--0015176f14ea006dbd04ad5e1781-- From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 20 12:32:17 2011 Received: (at 9562-done) by debbugs.gnu.org; 20 Sep 2011 16:32:17 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R63F2-0006h0-3w for submit@debbugs.gnu.org; Tue, 20 Sep 2011 12:32:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R63Ey-0006gr-WD for 9562-done@debbugs.gnu.org; Tue, 20 Sep 2011 12:32:15 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8KGR466027070 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 20 Sep 2011 12:27:04 -0400 Received: from [10.3.113.135] (ovpn-113-135.phx2.redhat.com [10.3.113.135]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p8KGR39M005152; Tue, 20 Sep 2011 12:27:03 -0400 Message-ID: <4E78BED2.9010704@redhat.com> Date: Tue, 20 Sep 2011 10:26:58 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.22) Gecko/20110906 Fedora/3.1.14-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.14 MIME-Version: 1.0 To: vijay krishna Subject: Re: bug#9562: unexpected sort behaviour References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Spam-Score: -10.3 (----------) X-Debbugs-Envelope-To: 9562-done Cc: 9562-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -10.3 (----------) force-merge 9562 9561 tag 9562 notabug thanks On 09/20/2011 05:51 AM, vijay krishna wrote: > Hello Team, > > May I please know the reason for the following behaviour of the sort > command... > Thanks for the report; however, this is not a bug. As mentioned in the FAQ, you are encountering this behavior because of your choice of locale: https://www.gnu.org/software/coreutils/faq/#Sort-does-not-sort-in-normal-order_0021 > 0 $ sort -k 1 bug2_file1 > b101 512 > b1 512 > ------------------ > sort (GNU coreutils) 5.97 Newer sort also comes with a --debug option that would help explain your predicament (5.97 is YEARS old; the latest is 8.13, with numerous bug fixes, although none of the behavior you show is affected by any of those bug fixes). $ printf 'b101 512\nb1 512\n' | LC_ALL=C sort -k1 --debug sort: using simple byte comparison b1 512 ______ ______ b101 512 ________ ________ $ printf 'b101 512\nb1 512\n' | sort -k1 --debug sort: using `en_US.UTF-8' sorting rules sort: leading blanks are significant in key 1; consider also specifying `b' b101 512 ________ ________ b1 512 ______ ______ $ printf 'b101 512\nb1 512\n' | sort -k1,1 --debug sort: using `en_US.UTF-8' sorting rules sort: leading blanks are significant in key 1; consider also specifying `b' b1 512 __ ______ b101 512 ____ ________ In the en_US.UTF-8 locale, collation is done by dictionary ordering, where whitespace is insignificant to the collation; and specification of -k1 instead of the more precise k1,1 means that you are sorting the entire line instead of the first field of the line. Since "b1512" collates greater than "b101512" in en_US collation rules, the same applies to "b1 512" and "b101 512". Notice how use of -k1,1 changed the output by comparing only "b1" and "b101", or how use of LC_ALL=C changed the output by switching to bytewise collation with no ditionary sorting, where space becomes significant. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 20 13:49:46 2011 Received: (at control) by debbugs.gnu.org; 20 Sep 2011 17:49:46 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R64S1-0000a6-PI for submit@debbugs.gnu.org; Tue, 20 Sep 2011 13:49:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R64Rx-0000Zt-S7 for control@debbugs.gnu.org; Tue, 20 Sep 2011 13:49:44 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8KHiW4O025308 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 20 Sep 2011 13:44:33 -0400 Received: from [10.3.113.135] (ovpn-113-135.phx2.redhat.com [10.3.113.135]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p8KHiWM5009764 for ; Tue, 20 Sep 2011 13:44:32 -0400 Message-ID: <4E78D100.1050106@redhat.com> Date: Tue, 20 Sep 2011 11:44:32 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.22) Gecko/20110906 Fedora/3.1.14-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.14 MIME-Version: 1.0 To: control@debbugs.gnu.org Subject: 9562 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -10.3 (----------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -10.3 (----------) force-merge 9562 9561 tag 9562 notabug thanks -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 20 13:54:05 2011 Received: (at control) by debbugs.gnu.org; 20 Sep 2011 17:54:05 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R64WC-0000ke-OI for submit@debbugs.gnu.org; Tue, 20 Sep 2011 13:54:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R64W9-0000k4-9u for control@debbugs.gnu.org; Tue, 20 Sep 2011 13:54:02 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8KHmqdQ009223 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 20 Sep 2011 13:48:52 -0400 Received: from [10.3.113.135] (ovpn-113-135.phx2.redhat.com [10.3.113.135]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p8KHmqS4026922 for ; Tue, 20 Sep 2011 13:48:52 -0400 Message-ID: <4E78D204.9000606@redhat.com> Date: Tue, 20 Sep 2011 11:48:52 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.22) Gecko/20110906 Fedora/3.1.14-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.14 MIME-Version: 1.0 To: control@debbugs.gnu.org Subject: 9562 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-Spam-Score: -10.3 (----------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -10.3 (----------) forcemerge 9562 9561 thanks -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org From unknown Fri Sep 05 11:02:25 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 19 Oct 2011 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator