From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 01 10:43:26 2014 Received: (at submit) by debbugs.gnu.org; 1 Aug 2014 14:43:26 +0000 Received: from localhost ([127.0.0.1]:54019 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XDE3J-00014i-79 for submit@debbugs.gnu.org; Fri, 01 Aug 2014 10:43:25 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60312) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XD9J1-0000br-1F for submit@debbugs.gnu.org; Fri, 01 Aug 2014 05:39:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XD9Il-00051Z-Q3 for submit@debbugs.gnu.org; Fri, 01 Aug 2014 05:39:13 -0400 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 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:51192) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XD9Il-00051S-Lg for submit@debbugs.gnu.org; Fri, 01 Aug 2014 05:39:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XD9Id-00078p-VO for bug-coreutils@gnu.org; Fri, 01 Aug 2014 05:39:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XD9IW-0004xn-G5 for bug-coreutils@gnu.org; Fri, 01 Aug 2014 05:38:55 -0400 Received: from mailout11.t-online.de ([194.25.134.85]:34585) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XD9IW-0004x9-92 for bug-coreutils@gnu.org; Fri, 01 Aug 2014 05:38:48 -0400 Received: from fwd33.aul.t-online.de (fwd33.aul.t-online.de [172.20.27.144]) by mailout11.t-online.de (Postfix) with SMTP id 6E5536EF0B for ; Fri, 1 Aug 2014 11:38:45 +0200 (CEST) Received: from schiller (GEXTcUZ6rh+Yx16rXpwVf45S3NSY940xCuxyWycQe3TBr8gSDzuGaEEPzNGohVWwtd@[217.247.189.31]) by fwd33.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1XD9IO-0VsZXs0; Fri, 1 Aug 2014 11:38:40 +0200 Date: Fri, 1 Aug 2014 11:38:39 +0200 (CEST) From: "Schleusener, Jens" To: bug-coreutils@gnu.org Subject: Bug in "sort -V" ? Message-ID: User-Agent: Alpine 2.19.9991 (LSU 64 2014-05-31) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-ID: GEXTcUZ6rh+Yx16rXpwVf45S3NSY940xCuxyWycQe3TBr8gSDzuGaEEPzNGohVWwtd X-TOI-MSGID: 32199a0e-5330-4124-ac54-2de1e8f8ff24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 01 Aug 2014 10:43:22 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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 am not sure if it's a bug or not but for my application cases the "sort" command with use of the very helpful option "-V" (natural sort of (version) numbers within text) not always delivers the by me expected output. Example input file (with four test cases): 1.0.5_src.tar.gz 1.0_src.tar.gz 2.0.5src.tar.gz 2.0src.tar.gz 3.0.5/ 3.0/ 4.0.5beta/ 4.0beta/ Sorted ("sort -V") output file (with errors?): 1.0.5_src.tar.gz 1.0_src.tar.gz 2.0src.tar.gz 2.0.5src.tar.gz 3.0.5/ 3.0/ 4.0beta/ 4.0.5beta/ By me expected output file: 1.0_src.tar.gz 1.0.5_src.tar.gz 2.0src.tar.gz 2.0.5src.tar.gz 3.0/ 3.0.5/ 4.0beta/ 4.0.5beta/ You see that the sort works correctly if after the [0-9\.]* part follows a alphabetic character but not if follows a non-alphabetic character like a slash or an underscore. Regards Jens From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 06 13:48:18 2018 Received: (at 18168) by debbugs.gnu.org; 6 Nov 2018 18:48:18 +0000 Received: from localhost ([127.0.0.1]:37783 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gK6Og-0001hy-CY for submit@debbugs.gnu.org; Tue, 06 Nov 2018 13:48:18 -0500 Received: from mail-pg1-f172.google.com ([209.85.215.172]:39304) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gK6Oe-0001hg-7y; Tue, 06 Nov 2018 13:48:16 -0500 Received: by mail-pg1-f172.google.com with SMTP id r9-v6so6200781pgv.6; Tue, 06 Nov 2018 10:48:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=WdmwtAQUjrqOJgN21JKQuRoWX5R9cU5az3qntBlCHPg=; b=UEiPHEumqLx3tjgHJrs3Pm8t7CJzltVBweB4pffO6RF/r6GkSr5P0WgvbaJGD572Uy 23OI/qTHHOLii8+xW+hbBWBfKmgOYeaMKCRUw9jP33u8ztDFnFbhH6qU9+pW6AcDNdUT jq/V68KFoHwh8awsJnb7aARl1PmMoVEVzcaxK4YhNK8i3OJNJhLFDCCK1VsxcLWKeSUK ZueV+w8yXZygxBRMd7dAncn/gn+6eZAg48VKdA1Yln6c6XrgYbsmru5X8LnI0jPiuyUV 2AcpTavMkSeTeLAVCZHLYVO2Dwm3C5GKp89JgxZlFhsdEF5/+Ocb1jo94SvI91tBDaMn 1imw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=WdmwtAQUjrqOJgN21JKQuRoWX5R9cU5az3qntBlCHPg=; b=j20ZtayceCm3kUzngxeu9gwp6+AFyuU5gW4/mpRMcR7lao1/DRKsqXL3bJN389wAL3 msVgcUNXnU2vk59LKw42pusZiiM2I+cWX/y61SjGfdYQNXOK9lxHBPx6TATgzsOQPfOg QS4ukm2+Bg9TYcwCagJYrTQVAVXyATsE7J3T/M4jsa/Fm9PUzO5qKbCJGMTtRNDPqeXj 9Qbc+3Qcfy0DXK/1ux5BCQUWtctvTZ/HEqw3OUzNv5qV5sZ7fEmEs03bTzOTXBINOPvo OevOuFxld3i0ABEsphCkrtd4dH2c9dvbhP0BtZxnJVVBCUH0o83Xhswq90KMEIkFipyW ICjg== X-Gm-Message-State: AGRZ1gIeGrWRqPdxTFkPuDwc7GiCh+dZ7bRB6Q3uWEhHB3GCgbGzpaKY cJwAnFWQsPJYDVUDOyKpDn2H+fMPOkk= X-Google-Smtp-Source: AJdET5fMZXfOFAykHyAa88IIqoYy7egIV7pfMtwkmcDB0ulErVHn/qk0Bihqs0uSuUfXHScMwF9J+w== X-Received: by 2002:a63:40c2:: with SMTP id n185-v6mr24974383pga.116.1541530089236; Tue, 06 Nov 2018 10:48:09 -0800 (PST) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id h62-v6sm48402503pfg.27.2018.11.06.10.48.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 10:48:08 -0800 (PST) Subject: Re: bug#18168: Bug in "sort -V" ? To: "Schleusener, Jens" , 18168@debbugs.gnu.org References: From: Assaf Gordon Message-ID: Date: Tue, 6 Nov 2018 11:48:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 18168 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 18168 notabug close 18168 stop (triaging old bugs) Hello, It seems your message was lost and not replied to in 4 years. Sorry about that. On 2014-08-01 3:38 a.m., Schleusener, Jens wrote: > I am not sure if it's a bug or not but for my application cases the > "sort" command with use of the very helpful option "-V" (natural sort of > (version) numbers within text) not always delivers the by me expected > output. Note that "-V/--version" is specifically sorting by Debian's *version* sorting rules. It might seem like it's the same as "natural sort", but it is not. The exact rules are here: https://www.debian.org/doc/debian-policy/ch-controlfields.html#version https://readme.phys.ethz.ch/documentation/debian_version_numbers/ > > Example input file (with four test cases): > > 1.0.5_src.tar.gz > 1.0_src.tar.gz > 2.0.5src.tar.gz > 2.0src.tar.gz > 3.0.5/ > 3.0/ > 4.0.5beta/ > 4.0beta/ > > Sorted ("sort -V") output file (with errors?): > > 1.0.5_src.tar.gz > 1.0_src.tar.gz > 2.0src.tar.gz > 2.0.5src.tar.gz > 3.0.5/ > 3.0/ > 4.0beta/ > 4.0.5beta/ > > By me expected output file: > > 1.0_src.tar.gz > 1.0.5_src.tar.gz > 2.0src.tar.gz > 2.0.5src.tar.gz > 3.0/ > 3.0.5/ > 4.0beta/ > 4.0.5beta/ The disagreement is about "1.0_src.tar.gz" vs "1.0.5_src.tar.gz" and "3.0/" vs "3.0.5/" . Note that these characters are not strictly valid characters in debian version strings. Let's try to compare them using Debian's own tools: First, define a tiny shell function to help compare strings: compver() { dpkg --compare-versions "$1" lt "$2" \ && printf "%s\n" "$1" "$2" \ || printf "%s\n" "$2" "$1" } Then, compare the values: $ compver 1.0.5_src.tar.gz 1.0_src.tar.gz dpkg: warning: version '1.0.5_src.tar.gz' has bad syntax: invalid character in version number dpkg: warning: version '1.0_src.tar.gz' has bad syntax: invalid character in version number 1.0.5_src.tar.gz 1.0_src.tar.gz $ compver 3.0/ 3.0.5/ dpkg: warning: version '3.0/' has bad syntax: invalid character in version number dpkg: warning: version '3.0.5/' has bad syntax: invalid character in version number 3.0.5/ 3.0/ So sort's order agrees with Debian's ordering rules. It might not be what a "natural sort" algorithm would do, but version-sort is not exactly natural-sort. Another detailed example of a version-sort is here: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22275 As such, I'm closing this bug. Discussion can continue by replying to this thread. -assaf From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 20 18:33:57 2018 Received: (at 18168) by debbugs.gnu.org; 20 Nov 2018 23:33:57 +0000 Received: from localhost ([127.0.0.1]:37560 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gPFWn-0004Hq-1o for submit@debbugs.gnu.org; Tue, 20 Nov 2018 18:33:57 -0500 Received: from ishtar.tlinx.org ([173.164.175.65]:50686 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gPFWl-0004Hi-Dh for 18168@debbugs.gnu.org; Tue, 20 Nov 2018 18:33:56 -0500 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id wAKNXpm3042886; Tue, 20 Nov 2018 15:33:53 -0800 Message-ID: <5BF499DF.90502@tlinx.org> Date: Tue, 20 Nov 2018 15:33:51 -0800 From: L A Walsh User-Agent: Thunderbird MIME-Version: 1.0 To: Assaf Gordon Subject: Re: bug#18168: Bug in "sort -V" ? References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 18168 Cc: "Schleusener, Jens" , 18168@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: -1.0 (-) On 11/6/2018 10:48 AM, Assaf Gordon wrote: > On 2014-08-01 3:38 a.m., Schleusener, Jens wrote: > >> I am not sure if it's a bug or not but for my application cases the >> "sort" command with use of the very helpful option "-V" (natural sort of >> (version) numbers within text) not always delivers the by me expected >> output. >> > > Note that "-V/--version" is specifically sorting by Debian's *version* > sorting rules. It might seem like it's the same as "natural sort", but > it is not. > The exact rules are here: > https://www.debian.org/doc/debian-policy/ch-controlfields.html#version > https://readme.phys.ethz.ch/documentation/debian_version_numbers/ > >> Example input file (with four test cases): >> 1.0.5_src.tar.gz >> 1.0_src.tar.gz >> 2.0.5src.tar.gz >> 2.0src.tar.gz >> 3.0.5/ >> 3.0/ >> 4.0.5beta/ >> 4.0beta/ >> >> Sorted ("sort -V") output file (with errors?): >> 1.0.5_src.tar.gz >> 1.0_src.tar.gz >> 2.0src.tar.gz >> 2.0.5src.tar.gz >> 3.0.5/ >> 3.0/ >> 4.0beta/ >> 4.0.5beta/ >> >> By me expected output file: >> 1.0_src.tar.gz >> 1.0.5_src.tar.gz >> 2.0src.tar.gz >> 2.0.5src.tar.gz >> 3.0/ >> 3.0.5/ >> 4.0beta/ >> 4.0.5beta/ >> > > The disagreement is about "1.0_src.tar.gz" vs "1.0.5_src.tar.gz" > and "3.0/" vs "3.0.5/" . > > Note that these characters are not strictly valid characters in debian > version strings. > --- I too would disagree with the above ordering. This bug had me go and look at 2 places where I compared version strings (I compared 2 algorithms) using the above as input, but removing the '/' which really shouldn't be part of the version string as it looks like output from ls (though I probably should add that case in my torture testing). My 2nd algorithm looks like I looked at sources from rpm probably derived from some debian order. My first algorithm I could justify as right or wrong gives the original posters expected order, but the 2nd(likely deb) gives the deb order -- almost. The addition of the '/' chars changes the sort order. Even that points to the assertion that "it shouldn't". I.e. in the 3.0 v. 3.0.5, the latter comes out 'greater' in deb rules rules (and mine) **BUT** 3.0/ v. 3.0.5/ and 3.0_ v. 3.0.5_ don't sort as might be expected, though these: 3.0- v. 3.0.5- 3.0() v 3.0.5() 3.0a v. 3.0.5a show the 2nd expr as greater. I am thinking such inconsistencies are a bit odd in a Version-sort, especially for a determinant tool? > Let's try to compare them using Debian's own tools: > > First, define a tiny shell function to help compare strings: > > compver() { > dpkg --compare-versions "$1" lt "$2" \ > && printf "%s\n" "$1" "$2" \ > || printf "%s\n" "$2" "$1" > } > > Then, compare the values: > > $ compver 1.0.5_src.tar.gz 1.0_src.tar.gz > dpkg: warning: version '1.0.5_src.tar.gz' has bad syntax: invalid > character in version number > dpkg: warning: version '1.0_src.tar.gz' has bad syntax: invalid > character in version number > 1.0.5_src.tar.gz > 1.0_src.tar.gz > > $ compver 3.0/ 3.0.5/ > dpkg: warning: version '3.0/' has bad syntax: invalid character in > version number > dpkg: warning: version '3.0.5/' has bad syntax: invalid character in > version number > 3.0.5/ > 3.0/ > > So sort's order agrees with Debian's ordering rules. > --- One might consider an error, to mean "indeterminant". Especially -- it should be the case that the tool sort documents how it sort(s) work within its manpages. -- hyperlinks to outside sources doesn't usually cut it for this type of program (console based -- _most_ consoles don't support hyperlinks). From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 21 13:12:27 2018 Received: (at 18168) by debbugs.gnu.org; 21 Nov 2018 18:12:27 +0000 Received: from localhost ([127.0.0.1]:40052 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gPWzD-0002WB-50 for submit@debbugs.gnu.org; Wed, 21 Nov 2018 13:12:27 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:57016) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gPWzB-0002Vx-38 for 18168@debbugs.gnu.org; Wed, 21 Nov 2018 13:12:25 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 25D53160098; Wed, 21 Nov 2018 10:12:19 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id SDHgUitil8Gq; Wed, 21 Nov 2018 10:12:18 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 746E1160097; Wed, 21 Nov 2018 10:12:18 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id tKJNqR1P6BsJ; Wed, 21 Nov 2018 10:12:18 -0800 (PST) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 4764316005F; Wed, 21 Nov 2018 10:12:18 -0800 (PST) Subject: Re: bug#18168: Bug in "sort -V" ? To: L A Walsh , Assaf Gordon References: <5BF499DF.90502@tlinx.org> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <088c9d67-ab72-09ba-d780-9b6eb880fd55@cs.ucla.edu> Date: Wed, 21 Nov 2018 10:12:18 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <5BF499DF.90502@tlinx.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 18168 Cc: "Schleusener, Jens" , 18168@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: -3.3 (---) I can't see us disagreeing with Debian. Perhaps you can file a bug report with Debian and get them to switch to the algorithm you prefer. From unknown Sun Jun 22 11:41:32 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 20 Dec 2018 12:24:06 +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