Re: Is Sort:Naturally a Little Off?

[email protected] (Smylers) Sat, 25 Sep 2021 08:01:03 +0100
Newsgroups perl.module-authors
Message-ID <[email protected]>
Shawn H Corey writes:

> I was testing different sort routines and I think I stopped a bug in
> Sort::Naturally (see attached script). It's output is:
>=20
> unsorted=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 : 4 A X i 1 x 10 a B =C3=A4 y z =C4=AF C =C3=84 b c =C4=AE=
 Y Z =C3=A4n and =C3=84ND
> And Any ant =C3=84m =C3=84s
>=20
> no locale,=C2=A0 perl=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : 1 10 4 A And Any =
B C X Y Z a and ant b c i x y z =C3=84
> =C3=84ND =C3=84m =C3=84s =C3=A4 =C3=A4n =C4=AE =C4=AF
> no locale,=C2=A0 naturally : 1 4 10 A a =C3=A4 =C3=84m And and =C3=84 =C3=
=A4n =C3=84ND ant Any =C3=84s B b C c
> i =C4=AE =C4=AF X x Y y Z z

That does look odd. Which locale are you running this under, which
version of Perl, and which version of Sort::Naturally?

Also, when I first ran your script I initially got lots of:

  Wide character in say at ./naturally line 23.

Adding this made Perl encode the output properly and the warning go
away:

  use open ':locale';

But that you didn't need to do that makes me think there's something
different about your set-up.

Also, even your =E2=80=98no locale, naturally=E2=80=99 line apparently *i=
s* affected by
the locale! With LC_COLLATE=3DC, I get:

  no locale,  naturally : 1 4 10 A a And and ant Any B b C c i X x Y y Z =
z =C3=84 =C3=A4 =C3=84m =C3=A4n =C3=84ND =C3=84s =C4=AE =C4=AF

Whereas with LC_COLLATE=3Den_GB.utf, it's:

  no locale,  naturally : 1 4 10 a A =C3=A4 =C3=84m and And =C3=84 =C3=A4=
n =C3=84ND ant Any =C3=84s b B c C i =C4=AF =C4=AE x X y Y z Z

Note that still isn't the same as your output, because capital letters
are sorting after lower-case, rather than before in yours.

That's with Perl v5.30.0 and Sort::Naturally 1.03.

> Is the =C3=84 out of place for the Sort::Naturally line?

It looks it to me. But there's clearly far more going on here than I
understand.

Smylers