Subject: | newline confuses sorting |
Date: | Mon, 10 Sep 2018 10:10:42 +0200 |
To: | bug-Sort-Naturally [...] rt.cpan.org |
From: | "Nilton Castillo" <Nilton.Castillo [...] ibm.com> |
Hello List,
Sorry if this has been discussed before, I could not find any
resolved/rejected bugs.
according to the documentation "\W substrings (neither words-characters nor
digits) are ignored. "
But there is a difference in sorting order when the list contains newlines,
here is a minimal example:
# Using the diamond operator to sort a list (for example, a file with
multiple lines)
[ncastill@psort]$ echo -e "A.1\nA.1.1\nA.2\nA.10" | perl -MSort::Naturally
-E 'print nsort <>'
A.1.1
A.1
A.2
A.10
# removing the newlines \n before sorting, then putting them back in the
output does sort it according to the documentation
[ncastill@psort]$ echo -e "A.1\nA.1.1\nA.2\nA.10" | perl -MSort::Naturally
-E 'chomp(@_=<>); say join "\n", nsort @_'
A.1
A.1.1
A.2
A.10
# newline \n does match \W
$ perl -E 'say "\n"=~/^\W+$/'
1
# also checked against latest version, and it is the same file as on my
system:
https://fastapi.metacpan.org/source/BINGOS/Sort-Naturally-1.03/lib/Sort/Naturally.pm
# Not sure what my complaint is, as there is a workaround. Maybe a note in
the documentation to chomp before nsort-ing. Hopefuly a fix.
# My environment:
This is perl 5, version 16, subversion 3 (v5.16.3) built for
x86_64-linux-thread-multi
[ncastill@psort]$ head -4 /usr/share/perl5/vendor_perl/Sort/Naturally.pm
require 5;
package Sort::Naturally; # Time-stamp: "2004-12-29 18:30:03 AST"
$VERSION = '1.03';
[ncastill@psort]$ uname -a
Linux oc1832383537.ibm.com 3.10.0-862.11.6.el7.x86_64 #1 SMP Fri Aug 10
16:55:11 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Cordiali saluti, salutări, S pozdravom, Met vriendelijke groeten,
Cordialement, With kind regards,
Nilton Castillo
IT Specialist Unix
GTS - UWV Unix Team
Office: HDK4-D IBM Nederland B.V.
Mobile: +31(0)6-24667440 Johan Huizingalaan
765
E-mail: Amsterdam, 1066 VH
nilton.castillo@ibm.com
Netherlands
Tenzij hierboven anders aangegeven: / Unless stated otherwise above:
IBM Nederland B.V.
Gevestigd te Amsterdam
Inschrijving Handelsregister Amsterdam Nr. 33054214