From unknown Wed Jun 18 23:17:13 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#24906 <24906@debbugs.gnu.org> To: bug#24906 <24906@debbugs.gnu.org> Subject: Status: gnu sort, what am I doing wrong? Reply-To: bug#24906 <24906@debbugs.gnu.org> Date: Thu, 19 Jun 2025 06:17:13 +0000 retitle 24906 gnu sort, what am I doing wrong? reassign 24906 coreutils submitter 24906 Arnold Robbins severity 24906 normal tag 24906 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 08 23:23:21 2016 Received: (at submit) by debbugs.gnu.org; 9 Nov 2016 04:23:22 +0000 Received: from localhost ([127.0.0.1]:50267 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c4KPx-0007z5-ON for submit@debbugs.gnu.org; Tue, 08 Nov 2016 23:23:21 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48112) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c4KPw-0007yt-Tb for submit@debbugs.gnu.org; Tue, 08 Nov 2016 23:23:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4KPq-0007RL-T7 for submit@debbugs.gnu.org; Tue, 08 Nov 2016 23:23:15 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_MANY_HDRS_LCASE autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:38640) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c4KPq-0007RH-Q3 for submit@debbugs.gnu.org; Tue, 08 Nov 2016 23:23:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4KPp-0000C6-M6 for bug-coreutils@gnu.org; Tue, 08 Nov 2016 23:23:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4KPl-0007R0-Nv for bug-coreutils@gnu.org; Tue, 08 Nov 2016 23:23:13 -0500 Received: from mxout2.netvision.net.il ([194.90.9.21]:51432) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4KPl-0007Qj-GR for bug-coreutils@gnu.org; Tue, 08 Nov 2016 23:23:09 -0500 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Received: from skeeve.com ([217.132.11.6]) by mxout2.netvision.net.il (Oracle Communications Messaging Server 7.0.5.30.0 64bit (built Oct 22 2013)) with ESMTPSA id <0OGC00EC3XIJQ460@mxout2.netvision.net.il> for bug-coreutils@gnu.org; Wed, 09 Nov 2016 06:23:07 +0200 (IST) Received: from skeeve.com (skeeve.com [127.0.0.1]) by skeeve.com (8.15.2/8.15.2/Debian-3) with ESMTP id uA94N6th003165 for ; Wed, 9 Nov 2016 06:23:06 +0200 Received: (from arnold@localhost) by skeeve.com (8.15.2/8.15.2/Submit) id uA94N6IN003164 for bug-coreutils@gnu.org; Wed, 9 Nov 2016 06:23:06 +0200 From: Arnold Robbins Message-id: <201611090423.uA94N6IN003164@skeeve.com> Date: Wed, 09 Nov 2016 06:23:06 +0200 To: bug-coreutils@gnu.org Subject: gnu sort, what am I doing wrong? User-Agent: Heirloom mailx 12.5 6/20/10 X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Hi. I'm trying to sort by the fifth field and then numerically in reverse order by the sixth field. $ sort --version sort (GNU coreutils) 8.25 Here's my data: $ cat checkbook.txt # Year : Month : Day : Recipient : D / W : Amount 2015:11:9:Joe's Coffee:W:5.00 2015:11:12:Mary's Doughnuts:W:5.00 2015:12:10:Joe's Coffee:W:10.00 2015:12:15:Mary's Doughnuts:W:10.00 2016:1:2:Hank's Party Store:W:35.00 2016:1:31:O'Reilly Media:D:100.00 And here's what I'm doing: $ grep -v ^# checkbook.txt | sort -t: -k5 -k6rg 2016:1:31:O'Reilly Media:D:100.00 2015:12:10:Joe's Coffee:W:10.00 2015:12:15:Mary's Doughnuts:W:10.00 2016:1:2:Hank's Party Store:W:35.00 2015:11:12:Mary's Doughnuts:W:5.00 2015:11:9:Joe's Coffee:W:5.00 Why aren't these sorted by amounts in descending order? What am I missing? Thanks, Arnold From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 09 01:14:44 2016 Received: (at 24906) by debbugs.gnu.org; 9 Nov 2016 06:14:44 +0000 Received: from localhost ([127.0.0.1]:50303 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c4M9j-0002Cd-Vp for submit@debbugs.gnu.org; Wed, 09 Nov 2016 01:14:44 -0500 Received: from mail-qk0-f178.google.com ([209.85.220.178]:34457) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c4M9i-0002CQ-Cl for 24906@debbugs.gnu.org; Wed, 09 Nov 2016 01:14:42 -0500 Received: by mail-qk0-f178.google.com with SMTP id q130so245059341qke.1 for <24906@debbugs.gnu.org>; Tue, 08 Nov 2016 22:14:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=UnR0BcwQqWJksA2ns8aJ7+70SGmvm4A+/r/lAn6Sv5I=; b=dnLFUOkKvEGmm+aAJxU5Z4V2A7cOoikpVMIlW7lq+Po4X7IK8ifkBSJXIt4P7i7DXx AUIYlC/vRt3OlP7vtM9IrZ8kEvL3L1GdZZw6leI9IhLAU34/hoB4D1blFKkKaNYiYI7k pXVTAXgv7TkP/qVWBJej7/db7+/0vvJfJQMBd11Efs8LNbmmI0tyyncAuN7/b2Ia2O1g ssRdx/VhLVl029aRMQOES26ADCAu6M8jI9g53/PQVi6MrEQBhukOsGA/hN7ifv+AIgLW E0vWdYzXbiagEMK6QnoNS10qmXpLPb7Kwc/zljkkMRGFOetagvv/GKPaUj7SNkPuYkDX PViQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=UnR0BcwQqWJksA2ns8aJ7+70SGmvm4A+/r/lAn6Sv5I=; b=i2pUudFr3qW9aX0jNo7fefWdUJJIbwR+PGnTxFSdrPSGkKKfw20iBIYlvT5CNOMXl9 +DDe5k90PKh3ITSm+y5j+ZNyNLujPwOxbeT+DdGO62c0xdssejVU02ubx2jlwBRQ4Qov alf3RUrWmOInD4dZdbEEJFtzxlTEx+PA2+NLJa9lGtaGQvtT/pfdW3SwJCFDbtTOfIfg cz3iGGPZ265ZYqkvDqusb6oj598SGjQ64be3nnHv1I8cUY1ZkfZPXTlMmkv+P7m3Eo12 25v7qW2NC7IE6J2OGHS4G7aMA2VBYGoNci/P3yeY1l6/im/3Z7WerW0CJBTE43M/B4o7 u+Xw== X-Gm-Message-State: ABUngvdee6p9s/Bd1ZNinnILiy19kEmMP+ecYFXU17g1Sqy8EsGGcCwXQi4UcvhhWuOpPg== X-Received: by 10.55.110.69 with SMTP id j66mr6511912qkc.92.1478672076973; Tue, 08 Nov 2016 22:14:36 -0800 (PST) Received: from [10.0.12.110] (ool-addc4864.static.optonline.net. [173.220.72.100]) by smtp.gmail.com with ESMTPSA id n188sm21460705qkc.30.2016.11.08.22.14.36 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Nov 2016 22:14:36 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2102\)) Subject: Re: bug#24906: gnu sort, what am I doing wrong? From: Assaf Gordon In-Reply-To: <201611090423.uA94N6IN003164@skeeve.com> Date: Wed, 9 Nov 2016 01:14:35 -0500 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201611090423.uA94N6IN003164@skeeve.com> To: Arnold Robbins X-Mailer: Apple Mail (2.2102) X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 24906 Cc: 24906@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) Hello Arnold, > On Nov 8, 2016, at 23:23, Arnold Robbins wrote: >=20 > $ grep -v ^# checkbook.txt | sort -t: -k5 -k6rg > [...] > Why aren't these sorted by amounts in descending order? > What am I missing? The option "-k5" means "field 5 till the end of the line", which = includes field 6. e.g "W:10.00" sorts before "W:35.00". You likely want "-k5,5" which means "field 5 only". The "--debug" option will show which part of each line is taken as the = sorting key: =3D=3D=3D $ grep -v ^# checkbook.txt | sort --debug -t: -k5 -k6rg sort: using =E2=80=98en_US.UTF-8=E2=80=99 sorting rules sort: key 2 is numeric and spans multiple fields 2016:1:31:O'Reilly Media:D:100.00 ________ ______ _________________________________ 2015:12:10:Joe's Coffee:W:10.00 _______ _____ _______________________________ 2015:12:15:Mary's Doughnuts:W:10.00 _______ _____ ___________________________________ 2016:1:2:Hank's Party Store:W:35.00 _______ _____ ___________________________________ 2015:11:12:Mary's Doughnuts:W:5.00 ______ ____ __________________________________ 2015:11:9:Joe's Coffee:W:5.00 ______ ____ _____________________________ =3D=3D=3D versus: =3D=3D=3D $ grep -v ^# checkbook.txt | sort --debug -t: -k5,5 -k6,6rg sort: using =E2=80=98en_US.UTF-8=E2=80=99 sorting rules 2016:1:31:O'Reilly Media:D:100.00 _ ______ _________________________________ 2016:1:2:Hank's Party Store:W:35.00 _ _____ ___________________________________ 2015:12:10:Joe's Coffee:W:10.00 _ _____ _______________________________ 2015:12:15:Mary's Doughnuts:W:10.00 _ _____ ___________________________________ 2015:11:12:Mary's Doughnuts:W:5.00 _ ____ __________________________________ 2015:11:9:Joe's Coffee:W:5.00 _ ____ _____________________________ =3D=3D=3D regards, - assaf From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 09 09:16:28 2016 Received: (at 24906) by debbugs.gnu.org; 9 Nov 2016 14:16:28 +0000 Received: from localhost ([127.0.0.1]:50598 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c4Tfw-0001OX-4i for submit@debbugs.gnu.org; Wed, 09 Nov 2016 09:16:28 -0500 Received: from freefriends.org ([96.88.95.60]:60768) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c4Tfv-0001OQ-3r for 24906@debbugs.gnu.org; Wed, 09 Nov 2016 09:16:27 -0500 X-Envelope-From: arnold@skeeve.com Received: from freefriends.org (localhost [127.0.0.1]) by freefriends.org (8.14.9/8.14.9) with ESMTP id uA9EBN2V002414; Wed, 9 Nov 2016 07:11:23 -0700 Received: (from arnold@localhost) by freefriends.org (8.14.9/8.14.9/submit) id uA9EBNgO002413; Wed, 9 Nov 2016 14:11:23 GMT From: arnold@skeeve.com Message-Id: <201611091411.uA9EBNgO002413@freefriends.org> X-Authentication-Warning: frenzy.freefriends.org: arnold set sender to arnold@skeeve.com using -f Date: Wed, 09 Nov 2016 07:11:23 -0700 To: assafgordon@gmail.com, arnold@skeeve.com Subject: Re: bug#24906: gnu sort, what am I doing wrong? References: <201611090423.uA94N6IN003164@skeeve.com> In-Reply-To: User-Agent: Heirloom mailx 12.4 7/29/08 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 24906 Cc: 24906@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Hi Assaf. Much thanks for the explanation. That makes sense and helps a lot. Arnold Assaf Gordon wrote: > Hello Arnold, > > > On Nov 8, 2016, at 23:23, Arnold Robbins wrote: > > > > $ grep -v ^# checkbook.txt | sort -t: -k5 -k6rg > > [...] > > Why aren't these sorted by amounts in descending order? > > What am I missing? > > The option "-k5" means "field 5 till the end of the line", which includes field 6. > e.g "W:10.00" sorts before "W:35.00". > You likely want "-k5,5" which means "field 5 only". > > The "--debug" option will show which part of each line is taken as the sorting key: > === > $ grep -v ^# checkbook.txt | sort --debug -t: -k5 -k6rg > sort: using ‘en_US.UTF-8’ sorting rules > sort: key 2 is numeric and spans multiple fields > 2016:1:31:O'Reilly Media:D:100.00 > ________ > ______ > _________________________________ > 2015:12:10:Joe's Coffee:W:10.00 > _______ > _____ > _______________________________ > 2015:12:15:Mary's Doughnuts:W:10.00 > _______ > _____ > ___________________________________ > 2016:1:2:Hank's Party Store:W:35.00 > _______ > _____ > ___________________________________ > 2015:11:12:Mary's Doughnuts:W:5.00 > ______ > ____ > __________________________________ > 2015:11:9:Joe's Coffee:W:5.00 > ______ > ____ > _____________________________ > > === > > versus: > > === > $ grep -v ^# checkbook.txt | sort --debug -t: -k5,5 -k6,6rg > sort: using ‘en_US.UTF-8’ sorting rules > 2016:1:31:O'Reilly Media:D:100.00 > _ > ______ > _________________________________ > 2016:1:2:Hank's Party Store:W:35.00 > _ > _____ > ___________________________________ > 2015:12:10:Joe's Coffee:W:10.00 > _ > _____ > _______________________________ > 2015:12:15:Mary's Doughnuts:W:10.00 > _ > _____ > ___________________________________ > 2015:11:12:Mary's Doughnuts:W:5.00 > _ > ____ > __________________________________ > 2015:11:9:Joe's Coffee:W:5.00 > _ > ____ > _____________________________ > === > > regards, > - assaf > From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 28 03:18:58 2018 Received: (at control) by debbugs.gnu.org; 28 Oct 2018 07:18:58 +0000 Received: from localhost ([127.0.0.1]:46406 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGfLe-0003gB-4X for submit@debbugs.gnu.org; Sun, 28 Oct 2018 03:18:58 -0400 Received: from mail-it1-f174.google.com ([209.85.166.174]:36820) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGfLd-0003fz-EL for control@debbugs.gnu.org; Sun, 28 Oct 2018 03:18:57 -0400 Received: by mail-it1-f174.google.com with SMTP id h14-v6so6148061itf.1 for ; Sun, 28 Oct 2018 00:18:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:message-id:date:user-agent:mime-version:content-language :content-transfer-encoding; bh=8nt/rXlgEKn9Aqm477Ic070MEV9I7rdHx9HE8SyfhGE=; b=PT+oKho/gUc0hqgv73sj6tKZy3KHPC4woVn/64GPlaVXI7yn+pDywCWbgYlvIqRJJl HWtR1pIjfLFiDadvwkdkEJWV03Aab0JfZkFG7L4P8hGp+INkL63ZgCoubEdlFBwwpqWu WEXhuA5GE1pS0co8+Mph2a0YG6nOTa1xG8Oix/g2TLLKK/0qFZpVoalVNi5gYqBYvZyZ DTnLoq5IMtl59ALrwgz1NjPOflLqtrY26dGxizDxnAAkIoL9NQRSF7A291TR+WMy8gmE 34Oc30m/ogwtdmSyf1vBriou3tZ9UZ/GSpbUvXibWh83iJvFRQQhE4XGNilapqBuG7lW JmAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=8nt/rXlgEKn9Aqm477Ic070MEV9I7rdHx9HE8SyfhGE=; b=Hh7w+yzG19tn1o+I3qZc91m59o50hIQPy8U79HOFhvqkoddQVV4x3FkIhH66+tIXoi 9CvgGQ4YLwtS2VBimnQad8TADRDwTC+ORRxlQKvD1Ef85vjmJEN+H+S8LTvnFWt8CTvy uUx/s9pRQdrU+An1L2ehW/c36PDsMMDqJui8DuL8HCQN88tZYDPsb+U7w6m0zq/m/n5f m4Ww8qDSccJZKYsCaWoFwlkzonFSe5Uz7P0kpqP5IAomhaNuOZdx/rXH24Et5J+gGkor BrOzMgoI2raJLGtPuCPkPykN5Od6wSwR65Cim0qalFdORelLyl1UHNqU6O+hyYpaXuoy Js+A== X-Gm-Message-State: AGRZ1gKitkLs5n4JAiPEhAWAkTqqZL6c9aiVATcjNKqyM9AuWLY+Iw5N BTMCmnMGM/E861odQRHTXYR3w8Dhrlg= X-Google-Smtp-Source: AJdET5f6Rn4sormoC1j12+VcUGSUoIGIJ8TKxDCvhTRdzLJtrX6p0XwFuUG1oZA291MnsdU0M2cDww== X-Received: by 2002:a05:660c:487:: with SMTP id a7mr7410854itk.90.1540711131587; Sun, 28 Oct 2018 00:18:51 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id c26-v6sm4627224itd.18.2018.10.28.00.18.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Oct 2018 00:18:50 -0700 (PDT) To: control@debbugs.gnu.org From: Assaf Gordon Message-ID: <27de4e25-b9d4-42c4-996d-daa4e21768c1@gmail.com> Date: Sun, 28 Oct 2018 01:18:49 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: tags 24906 notabug close 24906 [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.166.174 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (assafgordon[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) tags 24906 notabug close 24906 From unknown Wed Jun 18 23:17:13 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 25 Nov 2018 12:24:04 +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