need sort help

Hi All,

https://docs.perl6.org/routine/sort

How do I fix this?

$ ls | perl6 -e 'my @x=slurp(); say @x.sort'
(log.06-08-2018_16:07:39.zip
log.06-08-2018_17:07:39.zip
log.07-08-2018_06:07:39.zip
log.07-08-2018_16:07:39.zip
log.12-08-2016_06:07:39.zip
)


2016 should be at the top.


Many thanks,
-T
0
ToddAndMargo
6/9/2018 12:15:03 AM
perl.perl6.users 985 articles. 0 followers. Follow

24 Replies
48 Views

Similar Articles

[PageSpeed] 46

--0000000000000b0a69056e2b5e9f
Content-Type: text/plain; charset="UTF-8"

Rename all of the input files using ISO 8601 dates.  I can't tell, from
looking at those numbers, if the first field is the month or the day, so
it's impossible to sort data like that with certainty.

On Fri, Jun 8, 2018 at 5:15 PM, ToddAndMargo <ToddAndMargo@zoho.com> wrote:

> Hi All,
>
> https://docs.perl6.org/routine/sort
>
> How do I fix this?
>
> $ ls | perl6 -e 'my @x=slurp(); say @x.sort'
> (log.06-08-2018_16:07:39.zip
> log.06-08-2018_17:07:39.zip
> log.07-08-2018_06:07:39.zip
> log.07-08-2018_16:07:39.zip
> log.12-08-2016_06:07:39.zip
> )
>
>
> 2016 should be at the top.
>
>
> Many thanks,
> -T
>

--0000000000000b0a69056e2b5e9f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Rename all of the input files using ISO 8601 dates.=C2=A0 =
I can&#39;t tell, from looking at those numbers, if the first field is the =
month or the day, so it&#39;s impossible to sort data like that with certai=
nty.<br><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Fri, J=
un 8, 2018 at 5:15 PM, ToddAndMargo <span dir=3D"ltr">&lt;<a href=3D"mailto=
:ToddAndMargo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</a>&gt;</sp=
an> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;=
border-left:1px #ccc solid;padding-left:1ex">Hi All,<br>
<br>
<a href=3D"https://docs.perl6.org/routine/sort" rel=3D"noreferrer" target=
=3D"_blank">https://docs.perl6.org/routine<wbr>/sort</a><br>
<br>
How do I fix this?<br>
<br>
$ ls | perl6 -e &#39;my @x=3Dslurp(); say @x.sort&#39;<br>
(log.06-08-2018_16:07:39.zip<br>
log.06-08-2018_17:07:39.zip<br>
log.07-08-2018_06:07:39.zip<br>
log.07-08-2018_16:07:39.zip<br>
log.12-08-2016_06:07:39.zip<br>
)<br>
<br>
<br>
2016 should be at the top.<br>
<br>
<br>
Many thanks,<br>
-T<br>
</blockquote></div><br></div></div>

--0000000000000b0a69056e2b5e9f--
0
bslaabs
6/9/2018 1:23:43 AM
--0000000000001d3449056e2b7eed
Content-Type: text/plain; charset="UTF-8"

>
> On Fri, Jun 8, 2018 at 5:15 PM, ToddAndMargo <ToddAndMargo@zoho.com>
> wrote:
>>
>> How do I fix this?
>>
>> $ ls | perl6 -e 'my @x=slurp(); say @x.sort'
>> (log.06-08-2018_16:07:39.zip
>> log.06-08-2018_17:07:39.zip
>> log.07-08-2018_06:07:39.zip
>> log.07-08-2018_16:07:39.zip
>> log.12-08-2016_06:07:39.zip
>> )
>>
>>
>> 2016 should be at the top.
>>
>
On Fri, Jun 8, 2018 at 9:23 PM, Brent Laabs <bslaabs@gmail.com> wrote:

> Rename all of the input files using ISO 8601 dates.  I can't tell, from
> looking at those numbers, if the first field is the month or the day, so
> it's impossible to sort data like that with certainty.
>

You certainly *can* sort it the way they are, parse out the fields, order
them, and sort by the right parts, but Brent has the best answer..

For more information on ISO 8601, see https://xkcd.com/1179/

--0000000000001d3449056e2b7eed
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left=
:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div><div cl=
ass=3D"gmail-h5"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On F=
ri, Jun 8, 2018 at 5:15 PM, ToddAndMargo <span dir=3D"ltr">&lt;<a href=3D"m=
ailto:ToddAndMargo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</a>&gt=
;</span> wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p=
x 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
How do I fix this?<br>
<br>
$ ls | perl6 -e &#39;my @x=3Dslurp(); say @x.sort&#39;<br>
(log.06-08-2018_16:07:39.zip<br>
log.06-08-2018_17:07:39.zip<br>
log.07-08-2018_06:07:39.zip<br>
log.07-08-2018_16:07:39.zip<br>
log.12-08-2016_06:07:39.zip<br>
)<br>
<br>
<br>
2016 should be at the top.<br></blockquote></div></div></div></div></div>
</blockquote></div><div class=3D"gmail_extra"><br></div>On Fri, Jun 8, 2018=
 at 9:23 PM, Brent Laabs<span>=C2=A0</span><span dir=3D"ltr">&lt;<a href=3D=
"mailto:bslaabs@gmail.com" target=3D"_blank" style=3D"color:rgb(17,85,204)"=
>bslaabs@gmail.com</a>&gt;</span><span>=C2=A0</span>wrote:<br><blockquote c=
lass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px soli=
d rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><span style=3D"color:=
rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:norma=
l;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;le=
tter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;wh=
ite-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-de=
coration-style:initial;text-decoration-color:initial;float:none;display:inl=
ine">Rename all of the input files using ISO 8601 dates.=C2=A0 I can&#39;t =
tell, from looking at those numbers, if the first field is the month or the=
 day, so it&#39;s impossible to sort data like that with certainty.</span><=
/div></blockquote><br></div><div class=3D"gmail_extra">You certainly *can* =
sort it the way they are, parse out the fields, order them, and sort by the=
 right parts, but Brent has the best answer..</div><div class=3D"gmail_extr=
a"><br></div><div class=3D"gmail_extra">For more information on ISO 8601, s=
ee=C2=A0<a href=3D"https://xkcd.com/1179/">https://xkcd.com/1179/</a></div>=
<div class=3D"gmail_extra"><br></div></div>

--0000000000001d3449056e2b7eed--
0
curt
6/9/2018 1:32:21 AM
>> On Fri, Jun 8, 2018 at 5:15 PM, ToddAndMargo <ToddAndMargo@zoho.com=20
>> <mailto:ToddAndMargo@zoho.com>> wrote:
>>=20
>>     Hi All,
>>=20
>>     https://docs.perl6.org/routine/sort
>>     <https://docs.perl6.org/routine/sort>
>>=20
>>     How do I fix this?
>>=20
>>     $ ls | perl6 -e 'my @x=3Dslurp(); say @x.sort'
>>     (log.06-08-2018_16:07:39.zip
>>     log.06-08-2018_17:07:39.zip
>>     log.07-08-2018_06:07:39.zip
>>     log.07-08-2018_16:07:39.zip
>>     log.12-08-2016_06:07:39.zip
>>     )
>>=20
>>=20
>>     2016 should be at the top.
>>=20
>>=20
>>     Many thanks,
>>     -T

On 06/08/2018 06:23 PM, Brent Laabs wrote:
> Rename all of the input files using ISO 8601 dates.=C2=A0 I can't tell,=
 from=20
> looking at those numbers, if the first field is the month or the day, s=
o=20
> it's impossible to sort data like that with certainty.
>=20

That is the way the files come.

The convention being used is
     month, day, year, hour, minute, second
0
ToddAndMargo
6/9/2018 1:50:35 AM
--0000000000008472f8056e2bdd7d
Content-Type: text/plain; charset="UTF-8"

If possible, you should change the way the files come, or rename them when
you get them, or open an issue to use a proper output log format.

I mean, you can sort like:
@x.sort: {
  my $a = $^a ~~ m:g/\d+/;
  my $b = $^b ~~ m:g/\d+/;
  $a[6].defined cmp $b[6].defined
  ??
  || $a[3] cmp $b[3]
  || $a[1] cmp $b[1]
  || $a[2] cmp $b[2]
  || $a[4] cmp $b[4]
  || $a[5] cmp $b[5]
  || $a[6] cmp $b[6]
  || $a cmp $b
  !! $a cmp $b
};

You could make this more efficient with a Schwartzian transform so you
don't regex at every step.

But seriously, the problem is in the program that produces log files that
are hard to sort.  Why would someone do that?



On Fri, Jun 8, 2018 at 6:50 PM, ToddAndMargo <ToddAndMargo@zoho.com> wrote:

> On Fri, Jun 8, 2018 at 5:15 PM, ToddAndMargo <ToddAndMargo@zoho.com
>>> <mailto:ToddAndMargo@zoho.com>> wrote:
>>>
>>>     Hi All,
>>>
>>>     https://docs.perl6.org/routine/sort
>>>     <https://docs.perl6.org/routine/sort>
>>>
>>>     How do I fix this?
>>>
>>>     $ ls | perl6 -e 'my @x=slurp(); say @x.sort'
>>>     (log.06-08-2018_16:07:39.zip
>>>     log.06-08-2018_17:07:39.zip
>>>     log.07-08-2018_06:07:39.zip
>>>     log.07-08-2018_16:07:39.zip
>>>     log.12-08-2016_06:07:39.zip
>>>     )
>>>
>>>
>>>     2016 should be at the top.
>>>
>>>
>>>     Many thanks,
>>>     -T
>>>
>>
> On 06/08/2018 06:23 PM, Brent Laabs wrote:
>
>> Rename all of the input files using ISO 8601 dates.  I can't tell, from
>> looking at those numbers, if the first field is the month or the day, so
>> it's impossible to sort data like that with certainty.
>>
>>
> That is the way the files come.
>
> The convention being used is
>     month, day, year, hour, minute, second
>

--0000000000008472f8056e2bdd7d
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>If possible, you should change the way the files come=
, or rename them when you get them, or open an issue to use a proper output=
 log format.</div><div><div><br></div><div>I mean, you can sort like:</div>=
<div>@x.sort: {</div><div>=C2=A0 my $a =3D $^a ~~ m:g/\d+/;</div><div>=C2=
=A0 my $b =3D $^b ~~ m:g/\d+/;</div><div>=C2=A0 $a[6].defined cmp $b[6].def=
ined</div><div>=C2=A0 ??<br></div><div>=C2=A0 || $a[3] cmp $b[3]</div><div>=
=C2=A0 || $a[1] cmp $b[1]</div><div>=C2=A0 || $a[2] cmp $b[2]</div><div>=C2=
=A0 || $a[4] cmp $b[4]</div><div>=C2=A0 || $a[5] cmp $b[5]</div><div>=C2=A0=
 || $a[6] cmp $b[6]</div><div>=C2=A0 || $a cmp $b<br></div><div>=C2=A0 !! $=
a cmp $b<br></div><div>};</div><div><br></div><div>You could make this more=
 efficient with a Schwartzian transform so you don&#39;t regex at every ste=
p.</div><div><br></div><div>But seriously, the problem is in the program th=
at produces log files that are hard to sort.=C2=A0 Why would someone do tha=
t?<br></div><br></div><br></div><div class=3D"gmail_extra"><br><div class=
=3D"gmail_quote">On Fri, Jun 8, 2018 at 6:50 PM, ToddAndMargo <span dir=3D"=
ltr">&lt;<a href=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank">ToddAnd=
Margo@zoho.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><spa=
n class=3D""><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;b=
order-left:1px #ccc solid;padding-left:1ex"><blockquote class=3D"gmail_quot=
e" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Fri, Jun 8, 2018 at 5:15 PM, ToddAndMargo &lt;<a href=3D"mailto:ToddAndM=
argo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</a> &lt;mailto:<a hr=
ef=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com=
</a>&gt;<wbr>&gt; wrote:<br>
<br>
=C2=A0 =C2=A0 Hi All,<br>
<br>
=C2=A0 =C2=A0 <a href=3D"https://docs.perl6.org/routine/sort" rel=3D"norefe=
rrer" target=3D"_blank">https://docs.perl6.org/routine<wbr>/sort</a><br>
=C2=A0 =C2=A0 &lt;<a href=3D"https://docs.perl6.org/routine/sort" rel=3D"no=
referrer" target=3D"_blank">https://docs.perl6.org/routin<wbr>e/sort</a>&gt=
;<br>
<br>
=C2=A0 =C2=A0 How do I fix this?<br>
<br>
=C2=A0 =C2=A0 $ ls | perl6 -e &#39;my @x=3Dslurp(); say @x.sort&#39;<br>
=C2=A0 =C2=A0 (log.06-08-2018_16:07:39.zip<br>
=C2=A0 =C2=A0 log.06-08-2018_17:07:39.zip<br>
=C2=A0 =C2=A0 log.07-08-2018_06:07:39.zip<br>
=C2=A0 =C2=A0 log.07-08-2018_16:07:39.zip<br>
=C2=A0 =C2=A0 log.12-08-2016_06:07:39.zip<br>
=C2=A0 =C2=A0 )<br>
<br>
<br>
=C2=A0 =C2=A0 2016 should be at the top.<br>
<br>
<br>
=C2=A0 =C2=A0 Many thanks,<br>
=C2=A0 =C2=A0 -T<br>
</blockquote></blockquote>
<br></span><span class=3D"">
On 06/08/2018 06:23 PM, Brent Laabs wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
Rename all of the input files using ISO 8601 dates.=C2=A0 I can&#39;t tell,=
 from looking at those numbers, if the first field is the month or the day,=
 so it&#39;s impossible to sort data like that with certainty.<br>
<br>
</blockquote>
<br></span>
That is the way the files come.<br>
<br>
The convention being used is<br>
=C2=A0 =C2=A0 month, day, year, hour, minute, second<br>
</blockquote></div><br></div>

--0000000000008472f8056e2bdd7d--
0
bslaabs
6/9/2018 1:59:22 AM
--0000000000009ac0f0056e2be36e
Content-Type: text/plain; charset="UTF-8"

let me revise that

@x.sort: {
  my $a = $^a ~~ m:g/\d+/;
  my $b = $^b ~~ m:g/\d+/;
  $a[6].defined cmp $b[6].defined
  ??
    $a[3] cmp $b[3]
  || $a[1] cmp $b[1]
  || $a[2] cmp $b[2]
  || $a[4] cmp $b[4]
  || $a[5] cmp $b[5]
  || $a[6] cmp $b[6]
  || $^a cmp $^b
  !! $^a cmp $^b
};


On Fri, Jun 8, 2018 at 6:59 PM, Brent Laabs <bslaabs@gmail.com> wrote:

> If possible, you should change the way the files come, or rename them when
> you get them, or open an issue to use a proper output log format.
>
> I mean, you can sort like:
> @x.sort: {
>   my $a = $^a ~~ m:g/\d+/;
>   my $b = $^b ~~ m:g/\d+/;
>   $a[6].defined cmp $b[6].defined
>   ??
>   || $a[3] cmp $b[3]
>   || $a[1] cmp $b[1]
>   || $a[2] cmp $b[2]
>   || $a[4] cmp $b[4]
>   || $a[5] cmp $b[5]
>   || $a[6] cmp $b[6]
>   || $a cmp $b
>   !! $a cmp $b
> };
>
> You could make this more efficient with a Schwartzian transform so you
> don't regex at every step.
>
> But seriously, the problem is in the program that produces log files that
> are hard to sort.  Why would someone do that?
>
>
>
> On Fri, Jun 8, 2018 at 6:50 PM, ToddAndMargo <ToddAndMargo@zoho.com>
> wrote:
>
>> On Fri, Jun 8, 2018 at 5:15 PM, ToddAndMargo <ToddAndMargo@zoho.com
>>>> <mailto:ToddAndMargo@zoho.com>> wrote:
>>>>
>>>>     Hi All,
>>>>
>>>>     https://docs.perl6.org/routine/sort
>>>>     <https://docs.perl6.org/routine/sort>
>>>>
>>>>     How do I fix this?
>>>>
>>>>     $ ls | perl6 -e 'my @x=slurp(); say @x.sort'
>>>>     (log.06-08-2018_16:07:39.zip
>>>>     log.06-08-2018_17:07:39.zip
>>>>     log.07-08-2018_06:07:39.zip
>>>>     log.07-08-2018_16:07:39.zip
>>>>     log.12-08-2016_06:07:39.zip
>>>>     )
>>>>
>>>>
>>>>     2016 should be at the top.
>>>>
>>>>
>>>>     Many thanks,
>>>>     -T
>>>>
>>>
>> On 06/08/2018 06:23 PM, Brent Laabs wrote:
>>
>>> Rename all of the input files using ISO 8601 dates.  I can't tell, from
>>> looking at those numbers, if the first field is the month or the day, so
>>> it's impossible to sort data like that with certainty.
>>>
>>>
>> That is the way the files come.
>>
>> The convention being used is
>>     month, day, year, hour, minute, second
>>
>
>

--0000000000009ac0f0056e2be36e
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_quote"><div dir=3D"ltr"><div>let me re=
vise that</div><div><br></div><div><span class=3D""><div>@x.sort: {</div><d=
iv>=C2=A0 my $a =3D $^a ~~ m:g/\d+/;</div><div>=C2=A0 my $b =3D $^b ~~ m:g/=
\d+/;</div><div>=C2=A0 $a[6].defined cmp $b[6].defined</div><div>=C2=A0 ??<=
br></div><div>=C2=A0=C2=A0=C2=A0 $a[3] cmp $b[3]</div><div>=C2=A0 || $a[1] =
cmp $b[1]</div><div>=C2=A0 || $a[2] cmp $b[2]</div><div>=C2=A0 || $a[4] cmp=
 $b[4]</div><div>=C2=A0 || $a[5] cmp $b[5]</div><div>=C2=A0 || $a[6] cmp $b=
[6]</div></span><div>=C2=A0 || $^a cmp $^b<br></div><div>=C2=A0 !! $^a cmp =
$^b<br></div><div>};</div><br></div></div><div class=3D"HOEnZb"><div class=
=3D"h5"><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Fri, J=
un 8, 2018 at 6:59 PM, Brent Laabs <span dir=3D"ltr">&lt;<a href=3D"mailto:=
bslaabs@gmail.com" target=3D"_blank">bslaabs@gmail.com</a>&gt;</span> wrote=
:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-le=
ft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>If possible, you =
should change the way the files come, or rename them when you get them, or =
open an issue to use a proper output log format.</div><div><div><br></div><=
div>I mean, you can sort like:</div><div>@x.sort: {</div><div>=C2=A0 my $a =
=3D $^a ~~ m:g/\d+/;</div><div>=C2=A0 my $b =3D $^b ~~ m:g/\d+/;</div><div>=
=C2=A0 $a[6].defined cmp $b[6].defined</div><div>=C2=A0 ??<br></div><div>=
=C2=A0 || $a[3] cmp $b[3]</div><div>=C2=A0 || $a[1] cmp $b[1]</div><div>=C2=
=A0 || $a[2] cmp $b[2]</div><div>=C2=A0 || $a[4] cmp $b[4]</div><div>=C2=A0=
 || $a[5] cmp $b[5]</div><div>=C2=A0 || $a[6] cmp $b[6]</div><div>=C2=A0 ||=
 $a cmp $b<br></div><div>=C2=A0 !! $a cmp $b<br></div><div>};</div><div><br=
></div><div>You could make this more efficient with a Schwartzian transform=
 so you don&#39;t regex at every step.</div><div><br></div><div>But serious=
ly, the problem is in the program that produces log files that are hard to =
sort.=C2=A0 Why would someone do that?<br></div><br></div><br></div><div cl=
ass=3D"m_266981318916752147HOEnZb"><div class=3D"m_266981318916752147h5"><d=
iv class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Fri, Jun 8, 2018=
 at 6:50 PM, ToddAndMargo <span dir=3D"ltr">&lt;<a href=3D"mailto:ToddAndMa=
rgo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</a>&gt;</span> wrote:=
<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex"><span><blockquote class=3D"gmail_quote" =
style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #=
ccc solid;padding-left:1ex">
On Fri, Jun 8, 2018 at 5:15 PM, ToddAndMargo &lt;<a href=3D"mailto:ToddAndM=
argo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</a> &lt;mailto:<a hr=
ef=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com=
</a>&gt;<wbr>&gt; wrote:<br>
<br>
=C2=A0 =C2=A0 Hi All,<br>
<br>
=C2=A0 =C2=A0 <a href=3D"https://docs.perl6.org/routine/sort" rel=3D"norefe=
rrer" target=3D"_blank">https://docs.perl6.org/routine<wbr>/sort</a><br>
=C2=A0 =C2=A0 &lt;<a href=3D"https://docs.perl6.org/routine/sort" rel=3D"no=
referrer" target=3D"_blank">https://docs.perl6.org/routin<wbr>e/sort</a>&gt=
;<br>
<br>
=C2=A0 =C2=A0 How do I fix this?<br>
<br>
=C2=A0 =C2=A0 $ ls | perl6 -e &#39;my @x=3Dslurp(); say @x.sort&#39;<br>
=C2=A0 =C2=A0 (log.06-08-2018_16:07:39.zip<br>
=C2=A0 =C2=A0 log.06-08-2018_17:07:39.zip<br>
=C2=A0 =C2=A0 log.07-08-2018_06:07:39.zip<br>
=C2=A0 =C2=A0 log.07-08-2018_16:07:39.zip<br>
=C2=A0 =C2=A0 log.12-08-2016_06:07:39.zip<br>
=C2=A0 =C2=A0 )<br>
<br>
<br>
=C2=A0 =C2=A0 2016 should be at the top.<br>
<br>
<br>
=C2=A0 =C2=A0 Many thanks,<br>
=C2=A0 =C2=A0 -T<br>
</blockquote></blockquote>
<br></span><span>
On 06/08/2018 06:23 PM, Brent Laabs wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
Rename all of the input files using ISO 8601 dates.=C2=A0 I can&#39;t tell,=
 from looking at those numbers, if the first field is the month or the day,=
 so it&#39;s impossible to sort data like that with certainty.<br>
<br>
</blockquote>
<br></span>
That is the way the files come.<br>
<br>
The convention being used is<br>
=C2=A0 =C2=A0 month, day, year, hour, minute, second<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></div><br></div>

--0000000000009ac0f0056e2be36e--
0
bslaabs
6/9/2018 2:01:04 AM
 >>     On Fri, Jun 8, 2018 at 6:50 PM, ToddAndMargo <ToddAndMargo@zoho.com
 >>     <mailto:ToddAndMargo@zoho.com>> wrote:
 >>
 >>                 On Fri, Jun 8, 2018 at 5:15 PM, ToddAndMargo
 >>                 <ToddAndMargo@zoho.com <mailto:ToddAndMargo@zoho.com>
 >>                 <mailto:ToddAndMargo@zoho.com
 >>                 <mailto:ToddAndMargo@zoho.com>>> wrote:
 >>
 >>                      Hi All,
 >>
 >>                 https://docs.perl6.org/routine/sort
 >>                 <https://docs.perl6.org/routine/sort>
 >>                      <https://docs.perl6.org/routine/sort
 >>                 <https://docs.perl6.org/routine/sort>>
 >>
 >>                      How do I fix this?
 >>
 >>                      $ ls | perl6 -e 'my @x=slurp(); say @x.sort'
 >>                      (log.06-08-2018_16:07:39.zip
 >>                      log.06-08-2018_17:07:39.zip
 >>                      log.07-08-2018_06:07:39.zip
 >>                      log.07-08-2018_16:07:39.zip
 >>                      log.12-08-2016_06:07:39.zip
 >>                      )
 >>
 >>
 >>                      2016 should be at the top.
 >>
 >>
 >>                      Many thanks,
 >>                      -T
 >>
 >>
 >>         On 06/08/2018 06:23 PM, Brent Laabs wrote:
 >>
 >>             Rename all of the input files using ISO 8601 dates.  I can't
 >>             tell, from looking at those numbers, if the first field is
 >>             the month or the day, so it's impossible to sort data like
 >>             that with certainty.
 >>
 >>
 >>         That is the way the files come.
 >>
 >>         The convention being used is
 >>              month, day, year, hour, minute, second
 >>
 >>

 >> On Fri, Jun 8, 2018 at 6:59 PM, Brent Laabs <bslaabs@gmail.com
 >> <mailto:bslaabs@gmail.com>> wrote:
 >>
 >>     If possible, you should change the way the files come, or rename
 >>     them when you get them, or open an issue to use a proper output log
 >>     format.
 >>
 >>     I mean, you can sort like:
 >>     @x.sort: {
 >>        my $a = $^a ~~ m:g/\d+/;
 >>        my $b = $^b ~~ m:g/\d+/;
 >>        $a[6].defined cmp $b[6].defined
 >>        ??
 >>        || $a[3] cmp $b[3]
 >>        || $a[1] cmp $b[1]
 >>        || $a[2] cmp $b[2]
 >>        || $a[4] cmp $b[4]
 >>        || $a[5] cmp $b[5]
 >>        || $a[6] cmp $b[6]
 >>        || $a cmp $b
 >>        !! $a cmp $b
 >>     };
 >>
 >>     You could make this more efficient with a Schwartzian transform so
 >>     you don't regex at every step.
 >>
 >>     But seriously, the problem is in the program that produces log files
 >>     that are hard to sort.  Why would someone do that?

On 06/08/2018 07:00 PM, Brent Laabs wrote:
 > let me revise that
 >
 > @x.sort: {
 >    my $a = $^a ~~ m:g/\d+/;
 >    my $b = $^b ~~ m:g/\d+/;
 >    $a[6].defined cmp $b[6].defined
 >    ??
 >      $a[3] cmp $b[3]
 >    || $a[1] cmp $b[1]
 >    || $a[2] cmp $b[2]
 >    || $a[4] cmp $b[4]
 >    || $a[5] cmp $b[5]
 >    || $a[6] cmp $b[6]
 >    || $^a cmp $^b
 >    !! $^a cmp $^b
 > };
 >
 >

Not sure what I am looking at.  :'(
0
ToddAndMargo
6/9/2018 3:14:10 AM
On 06/08/2018 07:00 PM, Brent Laabs wrote:
> let me revise that
>=20
> @x.sort: {
>  =C2=A0 my $a =3D $^a ~~ m:g/\d+/;
>  =C2=A0 my $b =3D $^b ~~ m:g/\d+/;
>  =C2=A0 $a[6].defined cmp $b[6].defined
>  =C2=A0 ??
>  =C2=A0=C2=A0=C2=A0 $a[3] cmp $b[3]
>  =C2=A0 || $a[1] cmp $b[1]
>  =C2=A0 || $a[2] cmp $b[2]
>  =C2=A0 || $a[4] cmp $b[4]
>  =C2=A0 || $a[5] cmp $b[5]
>  =C2=A0 || $a[6] cmp $b[6]
>  =C2=A0 || $^a cmp $^b
>  =C2=A0 !! $^a cmp $^b
> };
>=20


$   ls | perl6 -e 'my @x=3Dslurp(); @x.sort: { my $a =3D $^a ~~ m:g/\d+/;=
my=20
$b =3D $^b ~~ m:g/\d+/;$a[6].defined cmp $b[6].defined ?? $a[3] cmp $b[3]=
=20
|| $a[1] cmp $b[1] || $a[2] cmp $b[2] || $a[4] cmp $b[4]  || $a[5] cmp=20
$b[5]  || $a[6] cmp $b[6] || $^a cmp $^b !! $^a cmp $^b a cmp $^b' $^a=20
cmp $^b
=3D=3D=3DSORRY!=3D=3D=3D Error while compiling -e
Redeclaration of symbol '$^a' as a placeholder parameter
at -e:1
------> my @x=3Dslurp(); @x.sort: { my $a =3D $^a=E2=8F=8F ~~ m:g/\d+/; m=
y $b =3D $^b=20
~~ m:g/\d+/;$a
0
ToddAndMargo
6/9/2018 3:52:36 AM
--000000000000e15af4056e2d9956
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Brent thinkoed that slightly. (Forgot that first use of a placeholder
"declares" it, and thereafter you don't use the ^. Which then collides with
the local "my" variables.)

> @x.sort: {
>    my $a =3D $^x ~~ m:g/\d+/;
>    my $b =3D $^y ~~ m:g/\d+/;
>    $a[6].defined cmp $b[6].defined
>    ??
>      $a[3] cmp $b[3]
>    || $a[1] cmp $b[1]
>    || $a[2] cmp $b[2]
>    || $a[4] cmp $b[4]
>    || $a[5] cmp $b[5]
>    || $a[6] cmp $b[6]
>    || $x cmp $y
>    !! $x cmp $y
> };

On Fri, Jun 8, 2018 at 11:53 PM ToddAndMargo <ToddAndMargo@zoho.com> wrote:

> On 06/08/2018 07:00 PM, Brent Laabs wrote:
> > let me revise that
> >
> > @x.sort: {
> >    my $a =3D $^a ~~ m:g/\d+/;
> >    my $b =3D $^b ~~ m:g/\d+/;
> >    $a[6].defined cmp $b[6].defined
> >    ??
> >      $a[3] cmp $b[3]
> >    || $a[1] cmp $b[1]
> >    || $a[2] cmp $b[2]
> >    || $a[4] cmp $b[4]
> >    || $a[5] cmp $b[5]
> >    || $a[6] cmp $b[6]
> >    || $^a cmp $^b
> >    !! $^a cmp $^b
> > };
> >
>
>
> $   ls | perl6 -e 'my @x=3Dslurp(); @x.sort: { my $a =3D $^a ~~ m:g/\d+/;=
my
> $b =3D $^b ~~ m:g/\d+/;$a[6].defined cmp $b[6].defined ?? $a[3] cmp $b[3]
> || $a[1] cmp $b[1] || $a[2] cmp $b[2] || $a[4] cmp $b[4]  || $a[5] cmp
> $b[5]  || $a[6] cmp $b[6] || $^a cmp $^b !! $^a cmp $^b a cmp $^b' $^a
> cmp $^b
> =3D=3D=3DSORRY!=3D=3D=3D Error while compiling -e
> Redeclaration of symbol '$^a' as a placeholder parameter
> at -e:1
> ------> my @x=3Dslurp(); @x.sort: { my $a =3D $^a=E2=8F=8F ~~ m:g/\d+/; m=
y $b =3D $^b
> ~~ m:g/\d+/;$a
>


--=20
brandon s allbery kf8nh                               sine nomine associate=
s
allbery.b@gmail.com                                  ballbery@sinenomine.ne=
t
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.ne=
t

--000000000000e15af4056e2d9956
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Brent thinkoed that slightly. (Forgot that first use of a =
placeholder &quot;declares&quot; it, and thereafter you don&#39;t use the ^=
.. Which then collides with the local &quot;my&quot; variables.)<div><br></d=
iv><div><span style=3D"color:rgb(80,0,80);background-color:rgb(255,255,255)=
;text-decoration-style:initial;text-decoration-color:initial;float:none;dis=
play:inline">&gt; @x.sort: {</span><br style=3D"color:rgb(80,0,80);backgrou=
nd-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-col=
or:initial"><span style=3D"color:rgb(80,0,80);background-color:rgb(255,255,=
255);text-decoration-style:initial;text-decoration-color:initial;float:none=
;display:inline">&gt;=C2=A0 =C2=A0 my $a =3D $^x ~~ m:g/\d+/;</span><br sty=
le=3D"color:rgb(80,0,80);background-color:rgb(255,255,255);text-decoration-=
style:initial;text-decoration-color:initial"><span style=3D"color:rgb(80,0,=
80);background-color:rgb(255,255,255);text-decoration-style:initial;text-de=
coration-color:initial;float:none;display:inline">&gt;=C2=A0 =C2=A0 my $b =
=3D $^y ~~ m:g/\d+/;</span><br style=3D"color:rgb(80,0,80);background-color=
:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initi=
al"><span style=3D"color:rgb(80,0,80);background-color:rgb(255,255,255);tex=
t-decoration-style:initial;text-decoration-color:initial;float:none;display=
:inline">&gt;=C2=A0 =C2=A0 $a[6].defined cmp $b[6].defined</span><br style=
=3D"color:rgb(80,0,80);background-color:rgb(255,255,255);text-decoration-st=
yle:initial;text-decoration-color:initial"><span style=3D"color:rgb(80,0,80=
);background-color:rgb(255,255,255);text-decoration-style:initial;text-deco=
ration-color:initial;float:none;display:inline">&gt;=C2=A0 =C2=A0 ??</span>=
<br style=3D"color:rgb(80,0,80);background-color:rgb(255,255,255);text-deco=
ration-style:initial;text-decoration-color:initial"><span style=3D"color:rg=
b(80,0,80);background-color:rgb(255,255,255);text-decoration-style:initial;=
text-decoration-color:initial;float:none;display:inline">&gt;=C2=A0 =C2=A0=
=C2=A0=C2=A0 $a[3] cmp $b[3]</span><br style=3D"color:rgb(80,0,80);backgrou=
nd-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-col=
or:initial"><span style=3D"color:rgb(80,0,80);background-color:rgb(255,255,=
255);text-decoration-style:initial;text-decoration-color:initial;float:none=
;display:inline">&gt;=C2=A0 =C2=A0 || $a[1] cmp $b[1]</span><br style=3D"co=
lor:rgb(80,0,80);background-color:rgb(255,255,255);text-decoration-style:in=
itial;text-decoration-color:initial"><span style=3D"color:rgb(80,0,80);back=
ground-color:rgb(255,255,255);text-decoration-style:initial;text-decoration=
-color:initial;float:none;display:inline">&gt;=C2=A0 =C2=A0 || $a[2] cmp $b=
[2]</span><br style=3D"color:rgb(80,0,80);background-color:rgb(255,255,255)=
;text-decoration-style:initial;text-decoration-color:initial"><span style=
=3D"color:rgb(80,0,80);background-color:rgb(255,255,255);text-decoration-st=
yle:initial;text-decoration-color:initial;float:none;display:inline">&gt;=
=C2=A0 =C2=A0 || $a[4] cmp $b[4]</span><br style=3D"color:rgb(80,0,80);back=
ground-color:rgb(255,255,255);text-decoration-style:initial;text-decoration=
-color:initial"><span style=3D"color:rgb(80,0,80);background-color:rgb(255,=
255,255);text-decoration-style:initial;text-decoration-color:initial;float:=
none;display:inline">&gt;=C2=A0 =C2=A0 || $a[5] cmp $b[5]</span><br style=
=3D"color:rgb(80,0,80);background-color:rgb(255,255,255);text-decoration-st=
yle:initial;text-decoration-color:initial"><span style=3D"color:rgb(80,0,80=
);background-color:rgb(255,255,255);text-decoration-style:initial;text-deco=
ration-color:initial;float:none;display:inline">&gt;=C2=A0 =C2=A0 || $a[6] =
cmp $b[6]</span><br style=3D"color:rgb(80,0,80);background-color:rgb(255,25=
5,255);text-decoration-style:initial;text-decoration-color:initial"><span s=
tyle=3D"color:rgb(80,0,80);background-color:rgb(255,255,255);text-decoratio=
n-style:initial;text-decoration-color:initial;float:none;display:inline">&g=
t;=C2=A0 =C2=A0 || $x cmp $y</span><br style=3D"color:rgb(80,0,80);backgrou=
nd-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-col=
or:initial"><span style=3D"color:rgb(80,0,80);background-color:rgb(255,255,=
255);text-decoration-style:initial;text-decoration-color:initial;float:none=
;display:inline">&gt;=C2=A0 =C2=A0 !! $x cmp $y</span><br style=3D"color:rg=
b(80,0,80);background-color:rgb(255,255,255);text-decoration-style:initial;=
text-decoration-color:initial"><span style=3D"color:rgb(80,0,80);background=
-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color=
:initial;float:none;display:inline">&gt; };</span><br></div></div><br><div =
class=3D"gmail_quote"><div dir=3D"ltr">On Fri, Jun 8, 2018 at 11:53 PM Todd=
AndMargo &lt;<a href=3D"mailto:ToddAndMargo@zoho.com">ToddAndMargo@zoho.com=
</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:=
0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 06/08/2018 07:00=
 PM, Brent Laabs wrote:<br>
&gt; let me revise that<br>
&gt; <br>
&gt; @x.sort: {<br>
&gt;=C2=A0 =C2=A0 my $a =3D $^a ~~ m:g/\d+/;<br>
&gt;=C2=A0 =C2=A0 my $b =3D $^b ~~ m:g/\d+/;<br>
&gt;=C2=A0 =C2=A0 $a[6].defined cmp $b[6].defined<br>
&gt;=C2=A0 =C2=A0 ??<br>
&gt;=C2=A0 =C2=A0=C2=A0=C2=A0 $a[3] cmp $b[3]<br>
&gt;=C2=A0 =C2=A0 || $a[1] cmp $b[1]<br>
&gt;=C2=A0 =C2=A0 || $a[2] cmp $b[2]<br>
&gt;=C2=A0 =C2=A0 || $a[4] cmp $b[4]<br>
&gt;=C2=A0 =C2=A0 || $a[5] cmp $b[5]<br>
&gt;=C2=A0 =C2=A0 || $a[6] cmp $b[6]<br>
&gt;=C2=A0 =C2=A0 || $^a cmp $^b<br>
&gt;=C2=A0 =C2=A0 !! $^a cmp $^b<br>
&gt; };<br>
&gt; <br>
<br>
<br>
$=C2=A0 =C2=A0ls | perl6 -e &#39;my @x=3Dslurp(); @x.sort: { my $a =3D $^a =
~~ m:g/\d+/;my <br>
$b =3D $^b ~~ m:g/\d+/;$a[6].defined cmp $b[6].defined ?? $a[3] cmp $b[3] <=
br>
|| $a[1] cmp $b[1] || $a[2] cmp $b[2] || $a[4] cmp $b[4]=C2=A0 || $a[5] cmp=
 <br>
$b[5]=C2=A0 || $a[6] cmp $b[6] || $^a cmp $^b !! $^a cmp $^b a cmp $^b&#39;=
 $^a <br>
cmp $^b<br>
=3D=3D=3DSORRY!=3D=3D=3D Error while compiling -e<br>
Redeclaration of symbol &#39;$^a&#39; as a placeholder parameter<br>
at -e:1<br>
------&gt; my @x=3Dslurp(); @x.sort: { my $a =3D $^a=E2=8F=8F ~~ m:g/\d+/; =
my $b =3D $^b <br>
~~ m:g/\d+/;$a<br>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
 class=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"l=
tr"><div>brandon s allbery kf8nh =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 =C2=A0 =C2=A0 sine nomine =
associates</div><div><a href=3D"mailto:allbery.b@gmail.com" target=3D"_blan=
k">allbery.b@gmail.com</a> =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 =C2=A0 =C2=A0 =C2=A0 =C2=A0<a hr=
ef=3D"mailto:ballbery@sinenomine.net" target=3D"_blank">ballbery@sinenomine=
..net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad =C2=A0 =
=C2=A0 =C2=A0 =C2=A0<a href=3D"http://sinenomine.net" target=3D"_blank">htt=
p://sinenomine.net</a></div></div></div>

--000000000000e15af4056e2d9956--
0
allbery
6/9/2018 4:03:26 AM
>>> @x.sort: {
>>>    my $a =3D $^x ~~ m:g/\d+/;
>>>    my $b =3D $^y ~~ m:g/\d+/;
>>>    $a[6].defined cmp $b[6].defined
>>>    ??
>>>      $a[3] cmp $b[3]
>>>    || $a[1] cmp $b[1]
>>>    || $a[2] cmp $b[2]
>>>    || $a[4] cmp $b[4]
>>>    || $a[5] cmp $b[5]
>>>    || $a[6] cmp $b[6]
>>>    || $x cmp $y
>>>    !! $x cmp $y
>>> };
>>=20
>> On Fri, Jun 8, 2018 at 11:53 PM ToddAndMargo <ToddAndMargo@zoho.com=20
>> <mailto:ToddAndMargo@zoho.com>> wrote:
>>=20
>>     On 06/08/2018 07:00 PM, Brent Laabs wrote:
>>      > let me revise that
>>      >
>>      > @x.sort: {
>>      >    my $a =3D $^a ~~ m:g/\d+/;
>>      >    my $b =3D $^b ~~ m:g/\d+/;
>>      >    $a[6].defined cmp $b[6].defined
>>      >    ??
>>      >      $a[3] cmp $b[3]
>>      >    || $a[1] cmp $b[1]
>>      >    || $a[2] cmp $b[2]
>>      >    || $a[4] cmp $b[4]
>>      >    || $a[5] cmp $b[5]
>>      >    || $a[6] cmp $b[6]
>>      >    || $^a cmp $^b
>>      >    !! $^a cmp $^b
>>      > };
>>      >
>>=20
>>=20
>>     $   ls | perl6 -e 'my @x=3Dslurp(); @x.sort: { my $a =3D $^a ~~ m:=
g/\d+/;my
>>     $b =3D $^b ~~ m:g/\d+/;$a[6].defined cmp $b[6].defined ?? $a[3] cm=
p $b[3]
>>     || $a[1] cmp $b[1] || $a[2] cmp $b[2] || $a[4] cmp $b[4]  || $a[5]=
 cmp
>>     $b[5]  || $a[6] cmp $b[6] || $^a cmp $^b !! $^a cmp $^b a cmp $^b'=
 $^a
>>     cmp $^b
>>     =3D=3D=3DSORRY!=3D=3D=3D Error while compiling -e
>>     Redeclaration of symbol '$^a' as a placeholder parameter
>>     at -e:1
>>     ------> my @x=3Dslurp(); @x.sort: { my $a =3D $^a=E2=8F=8F ~~ m:g/=
\d+/; my $b =3D $^b
>>     ~~ m:g/\d+/;$a

On 06/08/2018 09:03 PM, Brandon Allbery wrote:
> Brent thinkoed that slightly. (Forgot that first use of a placeholder=20
> "declares" it, and thereafter you don't use the ^. Which then collides =

> with the local "my" variables.)
>=20


$   ls | perl6 -e 'my @x=3Dslurp(); @x.sort: { my $a =3D $a ~~ m:g/\d+/; =
my=20
$b =3D $b ~~ m:g/\d+/;$a[6].defined cmp $b[6].defined ?? $a[3] cmp $b[3] =

|| $a[1] cmp $b[1] || $a[2] cmp $b[2] || $a[4] cmp $b[4]  || $a[5] cmp=20
$b[5]  || $a[6] cmp $b[6] || $^a cmp $^b !! $^a cmp $^b a cmp $^b' $^a=20
cmp $^b
=3D=3D=3DSORRY!=3D=3D=3D Error while compiling -e
Cannot use variable $a in declaration to initialize itself
at -e:1
------> my @x=3Dslurp(); @x.sort: { my $a =3D $=E2=8F=8Fa ~~ m:g/\d+/; my=
 $b =3D $b ~~=20
m:g/\d+/;$a
     expecting any of:
         term
0
ToddAndMargo
6/9/2018 4:11:24 AM
--0000000000009ab3d4056e2dc90a
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

You didn't use what I sent. It's $^x and $^y, not $a and $b.

(Aside: I *really* wish placeholders didn't work that way; this thread is
demonstrating why it's a bad idea. Not to mention a pain in the butt.)


On Sat, Jun 9, 2018 at 12:12 AM ToddAndMargo <ToddAndMargo@zoho.com> wrote:

> >>> @x.sort: {
> >>>    my $a =3D $^x ~~ m:g/\d+/;
> >>>    my $b =3D $^y ~~ m:g/\d+/;
> >>>    $a[6].defined cmp $b[6].defined
> >>>    ??
> >>>      $a[3] cmp $b[3]
> >>>    || $a[1] cmp $b[1]
> >>>    || $a[2] cmp $b[2]
> >>>    || $a[4] cmp $b[4]
> >>>    || $a[5] cmp $b[5]
> >>>    || $a[6] cmp $b[6]
> >>>    || $x cmp $y
> >>>    !! $x cmp $y
> >>> };
> >>
> >> On Fri, Jun 8, 2018 at 11:53 PM ToddAndMargo <ToddAndMargo@zoho.com
> >> <mailto:ToddAndMargo@zoho.com>> wrote:
> >>
> >>     On 06/08/2018 07:00 PM, Brent Laabs wrote:
> >>      > let me revise that
> >>      >
> >>      > @x.sort: {
> >>      >    my $a =3D $^a ~~ m:g/\d+/;
> >>      >    my $b =3D $^b ~~ m:g/\d+/;
> >>      >    $a[6].defined cmp $b[6].defined
> >>      >    ??
> >>      >      $a[3] cmp $b[3]
> >>      >    || $a[1] cmp $b[1]
> >>      >    || $a[2] cmp $b[2]
> >>      >    || $a[4] cmp $b[4]
> >>      >    || $a[5] cmp $b[5]
> >>      >    || $a[6] cmp $b[6]
> >>      >    || $^a cmp $^b
> >>      >    !! $^a cmp $^b
> >>      > };
> >>      >
> >>
> >>
> >>     $   ls | perl6 -e 'my @x=3Dslurp(); @x.sort: { my $a =3D $^a ~~
> m:g/\d+/;my
> >>     $b =3D $^b ~~ m:g/\d+/;$a[6].defined cmp $b[6].defined ?? $a[3] cm=
p
> $b[3]
> >>     || $a[1] cmp $b[1] || $a[2] cmp $b[2] || $a[4] cmp $b[4]  || $a[5]
> cmp
> >>     $b[5]  || $a[6] cmp $b[6] || $^a cmp $^b !! $^a cmp $^b a cmp $^b'
> $^a
> >>     cmp $^b
> >>     =3D=3D=3DSORRY!=3D=3D=3D Error while compiling -e
> >>     Redeclaration of symbol '$^a' as a placeholder parameter
> >>     at -e:1
> >>     ------> my @x=3Dslurp(); @x.sort: { my $a =3D $^a=E2=8F=8F ~~ m:g/=
\d+/; my $b =3D
> $^b
> >>     ~~ m:g/\d+/;$a
>
> On 06/08/2018 09:03 PM, Brandon Allbery wrote:
> > Brent thinkoed that slightly. (Forgot that first use of a placeholder
> > "declares" it, and thereafter you don't use the ^. Which then collides
> > with the local "my" variables.)
> >
>
>
> $   ls | perl6 -e 'my @x=3Dslurp(); @x.sort: { my $a =3D $a ~~ m:g/\d+/; =
my
> $b =3D $b ~~ m:g/\d+/;$a[6].defined cmp $b[6].defined ?? $a[3] cmp $b[3]
> || $a[1] cmp $b[1] || $a[2] cmp $b[2] || $a[4] cmp $b[4]  || $a[5] cmp
> $b[5]  || $a[6] cmp $b[6] || $^a cmp $^b !! $^a cmp $^b a cmp $^b' $^a
> cmp $^b
> =3D=3D=3DSORRY!=3D=3D=3D Error while compiling -e
> Cannot use variable $a in declaration to initialize itself
> at -e:1
> ------> my @x=3Dslurp(); @x.sort: { my $a =3D $=E2=8F=8Fa ~~ m:g/\d+/; my=
 $b =3D $b ~~
> m:g/\d+/;$a
>      expecting any of:
>          term
>


--=20
brandon s allbery kf8nh                               sine nomine associate=
s
allbery.b@gmail.com                                  ballbery@sinenomine.ne=
t
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.ne=
t

--0000000000009ab3d4056e2dc90a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>You didn&#39;t use what I sent. It&#39;s $^x and $^y,=
 not $a and $b.</div><div><br></div><div>(Aside: I *really* wish placeholde=
rs didn&#39;t work that way; this thread is demonstrating why it&#39;s a ba=
d idea. Not to mention a pain in the butt.)</div><div><span style=3D"color:=
rgb(80,0,80);background-color:rgb(255,255,255);text-decoration-style:initia=
l;text-decoration-color:initial;float:none;display:inline"><br></span></div=
></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Sat, Jun 9, 2018 =
at 12:12 AM ToddAndMargo &lt;<a href=3D"mailto:ToddAndMargo@zoho.com">ToddA=
ndMargo@zoho.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" =
style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">&gt=
;&gt;&gt; @x.sort: {<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 my $a =3D $^x ~~ m:g/\d+/;<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 my $b =3D $^y ~~ m:g/\d+/;<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 $a[6].defined cmp $b[6].defined<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 ??<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0 $a[3] cmp $b[3]<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 || $a[1] cmp $b[1]<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 || $a[2] cmp $b[2]<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 || $a[4] cmp $b[4]<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 || $a[5] cmp $b[5]<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 || $a[6] cmp $b[6]<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 || $x cmp $y<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 !! $x cmp $y<br>
&gt;&gt;&gt; };<br>
&gt;&gt; <br>
&gt;&gt; On Fri, Jun 8, 2018 at 11:53 PM ToddAndMargo &lt;<a href=3D"mailto=
:ToddAndMargo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</a> <br>
&gt;&gt; &lt;mailto:<a href=3D"mailto:ToddAndMargo@zoho.com" target=3D"_bla=
nk">ToddAndMargo@zoho.com</a>&gt;&gt; wrote:<br>
&gt;&gt; <br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0On 06/08/2018 07:00 PM, Brent Laabs wrote:<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 &gt; let me revise that<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 &gt;<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 &gt; @x.sort: {<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 &gt;=C2=A0 =C2=A0 my $a =3D $^a ~~ m:g/\d+/;<b=
r>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 &gt;=C2=A0 =C2=A0 my $b =3D $^b ~~ m:g/\d+/;<b=
r>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 &gt;=C2=A0 =C2=A0 $a[6].defined cmp $b[6].defi=
ned<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 &gt;=C2=A0 =C2=A0 ??<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 &gt;=C2=A0 =C2=A0 =C2=A0 $a[3] cmp $b[3]<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 &gt;=C2=A0 =C2=A0 || $a[1] cmp $b[1]<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 &gt;=C2=A0 =C2=A0 || $a[2] cmp $b[2]<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 &gt;=C2=A0 =C2=A0 || $a[4] cmp $b[4]<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 &gt;=C2=A0 =C2=A0 || $a[5] cmp $b[5]<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 &gt;=C2=A0 =C2=A0 || $a[6] cmp $b[6]<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 &gt;=C2=A0 =C2=A0 || $^a cmp $^b<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 &gt;=C2=A0 =C2=A0 !! $^a cmp $^b<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 &gt; };<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 &gt;<br>
&gt;&gt; <br>
&gt;&gt; <br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0$=C2=A0 =C2=A0ls | perl6 -e &#39;my @x=3Dslurp(=
); @x.sort: { my $a =3D $^a ~~ m:g/\d+/;my<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0$b =3D $^b ~~ m:g/\d+/;$a[6].defined cmp $b[6].=
defined ?? $a[3] cmp $b[3]<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0|| $a[1] cmp $b[1] || $a[2] cmp $b[2] || $a[4] =
cmp $b[4]=C2=A0 || $a[5] cmp<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0$b[5]=C2=A0 || $a[6] cmp $b[6] || $^a cmp $^b !=
! $^a cmp $^b a cmp $^b&#39; $^a<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0cmp $^b<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0=3D=3D=3DSORRY!=3D=3D=3D Error while compiling =
-e<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0Redeclaration of symbol &#39;$^a&#39; as a plac=
eholder parameter<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0at -e:1<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0------&gt; my @x=3Dslurp(); @x.sort: { my $a =
=3D $^a=E2=8F=8F ~~ m:g/\d+/; my $b =3D $^b<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0~~ m:g/\d+/;$a<br>
<br>
On 06/08/2018 09:03 PM, Brandon Allbery wrote:<br>
&gt; Brent thinkoed that slightly. (Forgot that first use of a placeholder =
<br>
&gt; &quot;declares&quot; it, and thereafter you don&#39;t use the ^. Which=
 then collides <br>
&gt; with the local &quot;my&quot; variables.)<br>
&gt; <br>
<br>
<br>
$=C2=A0 =C2=A0ls | perl6 -e &#39;my @x=3Dslurp(); @x.sort: { my $a =3D $a ~=
~ m:g/\d+/; my <br>
$b =3D $b ~~ m:g/\d+/;$a[6].defined cmp $b[6].defined ?? $a[3] cmp $b[3] <b=
r>
|| $a[1] cmp $b[1] || $a[2] cmp $b[2] || $a[4] cmp $b[4]=C2=A0 || $a[5] cmp=
 <br>
$b[5]=C2=A0 || $a[6] cmp $b[6] || $^a cmp $^b !! $^a cmp $^b a cmp $^b&#39;=
 $^a <br>
cmp $^b<br>
=3D=3D=3DSORRY!=3D=3D=3D Error while compiling -e<br>
Cannot use variable $a in declaration to initialize itself<br>
at -e:1<br>
------&gt; my @x=3Dslurp(); @x.sort: { my $a =3D $=E2=8F=8Fa ~~ m:g/\d+/; m=
y $b =3D $b ~~ <br>
m:g/\d+/;$a<br>
=C2=A0 =C2=A0 =C2=A0expecting any of:<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0term<br>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
 class=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"l=
tr"><div>brandon s allbery kf8nh =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 =C2=A0 =C2=A0 sine nomine =
associates</div><div><a href=3D"mailto:allbery.b@gmail.com" target=3D"_blan=
k">allbery.b@gmail.com</a> =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 =C2=A0 =C2=A0 =C2=A0 =C2=A0<a hr=
ef=3D"mailto:ballbery@sinenomine.net" target=3D"_blank">ballbery@sinenomine=
..net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad =C2=A0 =
=C2=A0 =C2=A0 =C2=A0<a href=3D"http://sinenomine.net" target=3D"_blank">htt=
p://sinenomine.net</a></div></div></div>

--0000000000009ab3d4056e2dc90a--
0
allbery
6/9/2018 4:16:47 AM
On 06/08/2018 09:16 PM, Brandon Allbery wrote:
> You didn't use what I sent. It's $^x and $^y, not $a and $b.

I am lost.  Would you mind writing it out for me?
0
ToddAndMargo
6/9/2018 4:19:06 AM
--0000000000003d12b8056e2de940
Content-Type: text/plain; charset="UTF-8"

@x.sort: {
   my $a = $^x ~~ m:g/\d+/;
   my $b = $^y ~~ m:g/\d+/;
   $a[6].defined cmp $b[6].defined
   ??
     $a[3] cmp $b[3]
   || $a[1] cmp $b[1]
   || $a[2] cmp $b[2]
   || $a[4] cmp $b[4]
   || $a[5] cmp $b[5]
   || $a[6] cmp $b[6]
   || $x cmp $y
   !! $x cmp $y
};

This is what I sent before, minus the leading "> " that I'd neglected to
remove.

Please note the second line does NOT say "my $a = $a ~~ m:g/\d+/;", which
is what you had and what produced the error you pasted. I don't know where
you got that. Likewise the third line with $b and $^y (where again you had
$b instead).

On Sat, Jun 9, 2018 at 12:19 AM ToddAndMargo <ToddAndMargo@zoho.com> wrote:

> On 06/08/2018 09:16 PM, Brandon Allbery wrote:
> > You didn't use what I sent. It's $^x and $^y, not $a and $b.
>
> I am lost.  Would you mind writing it out for me?
>


-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b@gmail.com                                  ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

--0000000000003d12b8056e2de940
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr" style=3D"text-decoration-style:initial;te=
xt-decoration-color:initial"><div><span style=3D"color:rgb(80,0,80);backgro=
und-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-co=
lor:initial;float:none;display:inline">@x.sort: {</span><br style=3D"color:=
rgb(80,0,80);background-color:rgb(255,255,255);text-decoration-style:initia=
l;text-decoration-color:initial"><span style=3D"color:rgb(80,0,80);backgrou=
nd-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-col=
or:initial;float:none;display:inline">=C2=A0 =C2=A0my $a =3D $^x ~~ m:g/\d+=
/;</span><br style=3D"color:rgb(80,0,80);background-color:rgb(255,255,255);=
text-decoration-style:initial;text-decoration-color:initial"><span style=3D=
"color:rgb(80,0,80);background-color:rgb(255,255,255);text-decoration-style=
:initial;text-decoration-color:initial;float:none;display:inline">=C2=A0 =
=C2=A0my $b =3D $^y ~~ m:g/\d+/;</span></div><div><span style=3D"color:rgb(=
80,0,80)">=C2=A0 =C2=A0$a[6].defined cmp $b[6].defined</span><div class=3D"=
gmail-adL"><span class=3D"gmail-im" style=3D"color:rgb(80,0,80)"><span styl=
e=3D"color:rgb(80,0,80);background-color:rgb(255,255,255);text-decoration-s=
tyle:initial;text-decoration-color:initial;float:none;display:inline">=C2=
=A0 =C2=A0??</span><br style=3D"color:rgb(80,0,80);background-color:rgb(255=
,255,255);text-decoration-style:initial;text-decoration-color:initial"><spa=
n style=3D"color:rgb(80,0,80);background-color:rgb(255,255,255);text-decora=
tion-style:initial;text-decoration-color:initial;float:none;display:inline"=
>=C2=A0 =C2=A0 =C2=A0$a[3] cmp $b[3]</span><br style=3D"color:rgb(80,0,80);=
background-color:rgb(255,255,255);text-decoration-style:initial;text-decora=
tion-color:initial"><span style=3D"color:rgb(80,0,80);background-color:rgb(=
255,255,255);text-decoration-style:initial;text-decoration-color:initial;fl=
oat:none;display:inline">=C2=A0 =C2=A0|| $a[1] cmp $b[1]</span><br style=3D=
"color:rgb(80,0,80);background-color:rgb(255,255,255);text-decoration-style=
:initial;text-decoration-color:initial"><span style=3D"color:rgb(80,0,80);b=
ackground-color:rgb(255,255,255);text-decoration-style:initial;text-decorat=
ion-color:initial;float:none;display:inline">=C2=A0 =C2=A0|| $a[2] cmp $b[2=
]</span><br style=3D"color:rgb(80,0,80);background-color:rgb(255,255,255);t=
ext-decoration-style:initial;text-decoration-color:initial"><span style=3D"=
color:rgb(80,0,80);background-color:rgb(255,255,255);text-decoration-style:=
initial;text-decoration-color:initial;float:none;display:inline">=C2=A0 =C2=
=A0|| $a[4] cmp $b[4]</span><br style=3D"color:rgb(80,0,80);background-colo=
r:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:init=
ial"><span style=3D"color:rgb(80,0,80);background-color:rgb(255,255,255);te=
xt-decoration-style:initial;text-decoration-color:initial;float:none;displa=
y:inline">=C2=A0 =C2=A0|| $a[5] cmp $b[5]</span><br style=3D"color:rgb(80,0=
,80);background-color:rgb(255,255,255);text-decoration-style:initial;text-d=
ecoration-color:initial"><span style=3D"color:rgb(80,0,80);background-color=
:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initi=
al;float:none;display:inline">=C2=A0 =C2=A0|| $a[6] cmp $b[6]</span><br sty=
le=3D"color:rgb(80,0,80);background-color:rgb(255,255,255);text-decoration-=
style:initial;text-decoration-color:initial"><span style=3D"color:rgb(80,0,=
80);background-color:rgb(255,255,255);text-decoration-style:initial;text-de=
coration-color:initial;float:none;display:inline">=C2=A0 =C2=A0|| $x cmp $y=
</span><br style=3D"color:rgb(80,0,80);background-color:rgb(255,255,255);te=
xt-decoration-style:initial;text-decoration-color:initial"><span style=3D"c=
olor:rgb(80,0,80);background-color:rgb(255,255,255);text-decoration-style:i=
nitial;text-decoration-color:initial;float:none;display:inline">=C2=A0 =C2=
=A0!! $x cmp $y</span><br style=3D"color:rgb(80,0,80);background-color:rgb(=
255,255,255);text-decoration-style:initial;text-decoration-color:initial"><=
span style=3D"color:rgb(80,0,80);background-color:rgb(255,255,255);text-dec=
oration-style:initial;text-decoration-color:initial;float:none;display:inli=
ne">};</span><br></span></div></div></div><br class=3D"gmail-Apple-intercha=
nge-newline">This is what I sent before, minus the leading &quot;&gt; &quot=
; that I&#39;d neglected to remove.<div><br></div><div>Please note the seco=
nd line does NOT say &quot;my $a =3D $a ~~ m:g/\d+/;&quot;, which is what y=
ou had and what produced the error you pasted. I don&#39;t know where you g=
ot that. Likewise the third line with $b and $^y (where again you had $b in=
stead).</div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Sat, =
Jun 9, 2018 at 12:19 AM ToddAndMargo &lt;<a href=3D"mailto:ToddAndMargo@zoh=
o.com">ToddAndMargo@zoho.com</a>&gt; wrote:<br></div><blockquote class=3D"g=
mail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-l=
eft:1ex">On 06/08/2018 09:16 PM, Brandon Allbery wrote:<br>
&gt; You didn&#39;t use what I sent. It&#39;s $^x and $^y, not $a and $b.<b=
r>
<br>
I am lost.=C2=A0 Would you mind writing it out for me?<br>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
 class=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"l=
tr"><div>brandon s allbery kf8nh =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 =C2=A0 =C2=A0 sine nomine =
associates</div><div><a href=3D"mailto:allbery.b@gmail.com" target=3D"_blan=
k">allbery.b@gmail.com</a> =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 =C2=A0 =C2=A0 =C2=A0 =C2=A0<a hr=
ef=3D"mailto:ballbery@sinenomine.net" target=3D"_blank">ballbery@sinenomine=
..net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad =C2=A0 =
=C2=A0 =C2=A0 =C2=A0<a href=3D"http://sinenomine.net" target=3D"_blank">htt=
p://sinenomine.net</a></div></div></div>

--0000000000003d12b8056e2de940--
0
allbery
6/9/2018 4:25:38 AM
On 06/08/2018 09:25 PM, Brandon Allbery wrote:
> @x.sort: {
>  =C2=A0 =C2=A0my $a =3D $^x ~~ m:g/\d+/;
>  =C2=A0 =C2=A0my $b =3D $^y ~~ m:g/\d+/;
>  =C2=A0 =C2=A0$a[6].defined cmp $b[6].defined
>  =C2=A0 =C2=A0??
>  =C2=A0 =C2=A0 =C2=A0$a[3] cmp $b[3]
>  =C2=A0 =C2=A0|| $a[1] cmp $b[1]
>  =C2=A0 =C2=A0|| $a[2] cmp $b[2]
>  =C2=A0 =C2=A0|| $a[4] cmp $b[4]
>  =C2=A0 =C2=A0|| $a[5] cmp $b[5]
>  =C2=A0 =C2=A0|| $a[6] cmp $b[6]
>  =C2=A0 =C2=A0|| $x cmp $y
>  =C2=A0 =C2=A0!! $x cmp $y
> };
>=20
> This is what I sent before, minus the leading "> " that I'd neglected t=
o=20
> remove.
>=20
> Please note the second line does NOT say "my $a =3D $a ~~ m:g/\d+/;",=20
> which is what you had and what produced the error you pasted. I don't=20
> know where you got that. Likewise the third line with $b and $^y (where=
=20
> again you had $b instead).
>=20

It compiles without error.  What variable is the result in?
0
ToddAndMargo
6/9/2018 4:36:25 AM
On 06/08/2018 09:25 PM, Brandon Allbery wrote:
> @x.sort: {
>  =C2=A0 =C2=A0my $a =3D $^x ~~ m:g/\d+/;
>  =C2=A0 =C2=A0my $b =3D $^y ~~ m:g/\d+/;
>  =C2=A0 =C2=A0$a[6].defined cmp $b[6].defined
>  =C2=A0 =C2=A0??
>  =C2=A0 =C2=A0 =C2=A0$a[3] cmp $b[3]
>  =C2=A0 =C2=A0|| $a[1] cmp $b[1]
>  =C2=A0 =C2=A0|| $a[2] cmp $b[2]
>  =C2=A0 =C2=A0|| $a[4] cmp $b[4]
>  =C2=A0 =C2=A0|| $a[5] cmp $b[5]
>  =C2=A0 =C2=A0|| $a[6] cmp $b[6]
>  =C2=A0 =C2=A0|| $x cmp $y
>  =C2=A0 =C2=A0!! $x cmp $y
> };
>=20
> This is what I sent before, minus the leading "> " that I'd neglected t=
o=20
> remove.
>=20
> Please note the second line does NOT say "my $a =3D $a ~~ m:g/\d+/;",=20
> which is what you had and what produced the error you pasted. I don't=20
> know where you got that. Likewise the third line with $b and $^y (where=
=20
> again you had $b instead).
>=20
> On Sat, Jun 9, 2018 at 12:19 AM ToddAndMargo <ToddAndMargo@zoho.com=20
> <mailto:ToddAndMargo@zoho.com>> wrote:
>=20
>     On 06/08/2018 09:16 PM, Brandon Allbery wrote:
>      > You didn't use what I sent. It's $^x and $^y, not $a and $b.
>=20
>     I am lost.=C2=A0 Would you mind writing it out for me?

$ ls | perl6 -e 'my @x=3Dslurp(); say @x.sort: {my $a =3D $^x ~~ m:g/\d+/=
;my=20
$b =3D $^y ~~ m:g/\d+/; $a[6].defined cmp $b[6].defined ??  $a[3] cmp=20
$b[3] || $a[1] cmp $b[1]   || $a[2] cmp $b[2]  || $a[4] cmp $b[4]  ||=20
$a[5] cmp $b[5]  || $a[6] cmp $b[6]  || $x cmp $y !! $x cmp $y};'
(cimtrak.log.06-08-2018_16:07:39.zip
cimtrak.log.06-08-2018_17:07:39.zip
cimtrak.log.07-08-2018_06:07:39.zip
cimtrak.log.07-08-2018_16:07:39.zip
cimtrak.log.12-08-2016_06:07:39.zip
)


:'(
0
ToddAndMargo
6/9/2018 4:37:29 AM
--0000000000008eb2e7056e2e2b8c
Content-Type: text/plain; charset="UTF-8"

It isn't in any variable, @x.sort got called in sink context.  You'll have
to assign it if you want, maybe use @x.=sort ?

I just wanted to give an example of how to solve the problem, not
necessarily a working solution.  First of all, I did thinko the solution --
element 6 is [5]...  and we don't really need to check the last bits of
time if we're going to do cmp anyway...

@x.=sort: {
    my $a = $^x ~~ m:g/\d+/;  # extract digit portions in to match object
for each parameter to sort
    my $b = $^y ~~ m:g/\d+/;  # ditto
    $a[5].defined cmp $b[5].defined   # this part makes sure we're actually
looking at a timestamp with 6 digit groups
    ??
      $a[3] cmp $b[3]   # year
    || $a[1] cmp $b[1]  # month
    || $a[2] cmp $b[2]  # day
    || $x cmp $y          # sort whatever's left
    !! $x cmp $y      # doesn't have a date stamp, then just string compare
};

The part about placeholders being declarations I didn't know, so hey, I'm
glad I participated.


On Fri, Jun 8, 2018 at 9:37 PM, ToddAndMargo <ToddAndMargo@zoho.com> wrote:

> On 06/08/2018 09:25 PM, Brandon Allbery wrote:
>
>> @x.sort: {
>>     my $a = $^x ~~ m:g/\d+/;
>>     my $b = $^y ~~ m:g/\d+/;
>>     $a[6].defined cmp $b[6].defined
>>     ??
>>       $a[3] cmp $b[3]
>>     || $a[1] cmp $b[1]
>>     || $a[2] cmp $b[2]
>>     || $a[4] cmp $b[4]
>>     || $a[5] cmp $b[5]
>>     || $a[6] cmp $b[6]
>>     || $x cmp $y
>>     !! $x cmp $y
>> };
>>
>> This is what I sent before, minus the leading "> " that I'd neglected to
>> remove.
>>
>> Please note the second line does NOT say "my $a = $a ~~ m:g/\d+/;", which
>> is what you had and what produced the error you pasted. I don't know where
>> you got that. Likewise the third line with $b and $^y (where again you had
>> $b instead).
>>
>> On Sat, Jun 9, 2018 at 12:19 AM ToddAndMargo <ToddAndMargo@zoho.com
>> <mailto:ToddAndMargo@zoho.com>> wrote:
>>
>>     On 06/08/2018 09:16 PM, Brandon Allbery wrote:
>>      > You didn't use what I sent. It's $^x and $^y, not $a and $b.
>>
>>     I am lost.  Would you mind writing it out for me?
>>
>
> $ ls | perl6 -e 'my @x=slurp(); say @x.sort: {my $a = $^x ~~ m:g/\d+/;my
> $b = $^y ~~ m:g/\d+/; $a[6].defined cmp $b[6].defined ??  $a[3] cmp $b[3]
> || $a[1] cmp $b[1]   || $a[2] cmp $b[2]  || $a[4] cmp $b[4]  || $a[5] cmp
> $b[5]  || $a[6] cmp $b[6]  || $x cmp $y !! $x cmp $y};'
> (cimtrak.log.06-08-2018_16:07:39.zip
> cimtrak.log.06-08-2018_17:07:39.zip
> cimtrak.log.07-08-2018_06:07:39.zip
> cimtrak.log.07-08-2018_16:07:39.zip
> cimtrak.log.12-08-2016_06:07:39.zip
> )
>
>
> :'(
>

--0000000000008eb2e7056e2e2b8c
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>It isn&#39;t in any variable, @x.sort got called in s=
ink context.=C2=A0 You&#39;ll have to assign it if you want, maybe use @x.=
=3Dsort ?<br></div><div><br></div><div>I
 just wanted to give an example of how to solve the problem, not=20
necessarily a working solution.=C2=A0 First of all, I did thinko the soluti=
on
 -- element 6 is [5]...=C2=A0 and we don&#39;t really need to check the las=
t bits
 of time if we&#39;re going to do cmp anyway...</div><div><br></div><div><s=
pan class=3D"gmail-m_5890033143143457116gmail-im">@x.=3Dsort: {<br>
=C2=A0=C2=A0 =C2=A0my $a =3D $^x ~~ m:g/\d+/;=C2=A0 # extract digit portion=
s in to match object for each parameter to sort</span></div><div><span clas=
s=3D"gmail-m_5890033143143457116gmail-im">=C2=A0=C2=A0=C2=A0 my $b =3D $^y =
~~ m:g/\d+/;=C2=A0 # ditto<br>
=C2=A0=C2=A0 =C2=A0$a[5].defined cmp $b[5].defined=C2=A0=C2=A0 # this part =
makes sure we&#39;re actually looking at a timestamp with 6 digit groups<br=
>
=C2=A0=C2=A0 =C2=A0??<br>
=C2=A0=C2=A0 =C2=A0 =C2=A0$a[3] cmp $b[3]=C2=A0=C2=A0 # year<br>
=C2=A0=C2=A0 =C2=A0|| $a[1] cmp $b[1]=C2=A0 # month<br>
=C2=A0=C2=A0 =C2=A0|| $a[2] cmp $b[2]=C2=A0 # day<br>
=C2=A0=C2=A0 =C2=A0|| $x cmp $y=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 # sort whatever&#39;s left<br>
=C2=A0=C2=A0 =C2=A0!! $x cmp $y=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # doesn&#39;t=
 have a date stamp, then just string compare<br>
};</span></div><div><span class=3D"gmail-m_5890033143143457116gmail-im"><br=
></span></div><div><span class=3D"gmail-m_5890033143143457116gmail-im">The =
part about placeholders being declarations I didn&#39;t know, so hey, I&#39=
;m glad I participated.</span></div><br><div class=3D"gmail_extra"><br><div=
 class=3D"gmail_quote">On Fri, Jun 8, 2018 at 9:37 PM, ToddAndMargo <span d=
ir=3D"ltr">&lt;<a href=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank">T=
oddAndMargo@zoho.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_qu=
ote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex=
"><span class=3D"">On 06/08/2018 09:25 PM, Brandon Allbery wrote:<br>
</span><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-=
left:1px #ccc solid;padding-left:1ex"><span class=3D"">
@x.sort: {<br>
=C2=A0=C2=A0 =C2=A0my $a =3D $^x ~~ m:g/\d+/;<br>
=C2=A0=C2=A0 =C2=A0my $b =3D $^y ~~ m:g/\d+/;<br>
=C2=A0=C2=A0 =C2=A0$a[6].defined cmp $b[6].defined<br>
=C2=A0=C2=A0 =C2=A0??<br>
=C2=A0=C2=A0 =C2=A0 =C2=A0$a[3] cmp $b[3]<br>
=C2=A0=C2=A0 =C2=A0|| $a[1] cmp $b[1]<br>
=C2=A0=C2=A0 =C2=A0|| $a[2] cmp $b[2]<br>
=C2=A0=C2=A0 =C2=A0|| $a[4] cmp $b[4]<br>
=C2=A0=C2=A0 =C2=A0|| $a[5] cmp $b[5]<br>
=C2=A0=C2=A0 =C2=A0|| $a[6] cmp $b[6]<br>
=C2=A0=C2=A0 =C2=A0|| $x cmp $y<br>
=C2=A0=C2=A0 =C2=A0!! $x cmp $y<br>
};<br>
<br>
This is what I sent before, minus the leading &quot;&gt; &quot; that I&#39;=
d neglected to remove.<br>
<br>
Please note the second line does NOT say &quot;my $a =3D $a ~~ m:g/\d+/;&qu=
ot;, which is what you had and what produced the error you pasted. I don&#3=
9;t know where you got that. Likewise the third line with $b and $^y (where=
 again you had $b instead).<br>
<br></span><span class=3D"">
On Sat, Jun 9, 2018 at 12:19 AM ToddAndMargo &lt;<a href=3D"mailto:ToddAndM=
argo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</a> &lt;mailto:<a hr=
ef=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com=
</a>&gt;<wbr>&gt; wrote:<br>
<br>
=C2=A0 =C2=A0 On 06/08/2018 09:16 PM, Brandon Allbery wrote:<br>
=C2=A0 =C2=A0 =C2=A0&gt; You didn&#39;t use what I sent. It&#39;s $^x and $=
^y, not $a and $b.<br>
<br>
=C2=A0 =C2=A0 I am lost.=C2=A0 Would you mind writing it out for me?<br>
</span></blockquote>
<br>
$ ls | perl6 -e &#39;my @x=3Dslurp(); say @x.sort: {my $a =3D $^x ~~ m:g/\d=
+/;my $b =3D $^y ~~ m:g/\d+/; $a[6].defined cmp $b[6].defined ??=C2=A0 $a[3=
] cmp $b[3] || $a[1] cmp $b[1]=C2=A0 =C2=A0|| $a[2] cmp $b[2]=C2=A0 || $a[4=
] cmp $b[4]=C2=A0 || $a[5] cmp $b[5]=C2=A0 || $a[6] cmp $b[6]=C2=A0 || $x c=
mp $y !! $x cmp $y};&#39;<br>
(cimtrak.log.06-08-2018_16:07:<wbr>39.zip<br>
cimtrak.log.06-08-2018_17:07:3<wbr>9.zip<br>
cimtrak.log.07-08-2018_06:07:3<wbr>9.zip<br>
cimtrak.log.07-08-2018_16:07:3<wbr>9.zip<br>
cimtrak.log.12-08-2016_06:07:3<wbr>9.zip<br>
)<br>
<br>
<br>
:&#39;(<br>
</blockquote></div><br></div></div>

--0000000000008eb2e7056e2e2b8c--
0
bslaabs
6/9/2018 4:44:21 AM
On 06/08/2018 09:44 PM, Brent Laabs wrote:
> It isn't in any variable, @x.sort got called in sink context.=C2=A0 You=
'll=20
> have to assign it if you want, maybe use @x.=3Dsort ?
>=20

Is alright.  I didn't understand what was happening anyway.
Thank you for the help!
0
ToddAndMargo
6/9/2018 4:46:50 AM
That's unnecessarily long and complicated, here's how you can do it much
easier:

=C2=A0=C2=A0=C2=A0 @x.sort: {
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 my ($month, $day, $year, $hour=
, $minute, $second) =3D .comb(/\d+/);
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ($year // 0, $month // 0, $day=
 // 0, $hour // 0, $minute // 0,
$second // 0, $_);
=C2=A0=C2=A0=C2=A0 }

Trying it on some input data:

=C2=A0=C2=A0=C2=A0 cimtrak.log.06-08-2018_16:07:39.zip
=C2=A0=C2=A0=C2=A0 cimtrak.log.06-08-2018_17:07:39.zip
=C2=A0=C2=A0=C2=A0 cimtrak.log.07-08-2018_06:07:39.zip
=C2=A0=C2=A0=C2=A0 cimtrak.log.07-08-2018_16:07:39.zip
=C2=A0=C2=A0=C2=A0 cimtrak.log.12-08-2016_06:07:39.zip
=C2=A0=C2=A0=C2=A0 cookies
=C2=A0=C2=A0=C2=A0 asbestos
=C2=A0=C2=A0=C2=A0 fire engine
=C2=A0=C2=A0=C2=A0 perl6
=C2=A0=C2=A0=C2=A0 butterflies

results in:

=C2=A0=C2=A0=C2=A0 asbestos
=C2=A0=C2=A0=C2=A0 butterflies
=C2=A0=C2=A0=C2=A0 cookies
=C2=A0=C2=A0=C2=A0 fire engine
=C2=A0=C2=A0=C2=A0 perl6
=C2=A0=C2=A0=C2=A0 cimtrak.log.12-08-2016_06:07:39.zip
=C2=A0=C2=A0=C2=A0 cimtrak.log.06-08-2018_16:07:39.zip
=C2=A0=C2=A0=C2=A0 cimtrak.log.06-08-2018_17:07:39.zip
=C2=A0=C2=A0=C2=A0 cimtrak.log.07-08-2018_06:07:39.zip
=C2=A0=C2=A0=C2=A0 cimtrak.log.07-08-2018_16:07:39.zip

This is the schwartzian transform that was mentioned in another mail.
why it wasn't actually shown, i have no clue :)

Hope that helps
=C2=A0 - Timo
0
timo
6/9/2018 4:51:29 AM
If you want to make it robust in the case of fields being different
length, like having entries with the day as "5" instead of "05", you can
put a >>.Int after the .comb(/\d+/) and that'll give you proper numeric
sorting for all fields regardless of width.


On 09/06/18 06:51, Timo Paulssen wrote:
> That's unnecessarily long and complicated, here's how you can do it muc=
h
> easier:
>
> =C2=A0=C2=A0=C2=A0 @x.sort: {
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 my ($month, $day, $year, $ho=
ur, $minute, $second) =3D .comb(/\d+/);
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ($year // 0, $month // 0, $d=
ay // 0, $hour // 0, $minute // 0,
> $second // 0, $_);
> =C2=A0=C2=A0=C2=A0 }
>
> Trying it on some input data:
>
> =C2=A0=C2=A0=C2=A0 cimtrak.log.06-08-2018_16:07:39.zip
> =C2=A0=C2=A0=C2=A0 cimtrak.log.06-08-2018_17:07:39.zip
> =C2=A0=C2=A0=C2=A0 cimtrak.log.07-08-2018_06:07:39.zip
> =C2=A0=C2=A0=C2=A0 cimtrak.log.07-08-2018_16:07:39.zip
> =C2=A0=C2=A0=C2=A0 cimtrak.log.12-08-2016_06:07:39.zip
> =C2=A0=C2=A0=C2=A0 cookies
> =C2=A0=C2=A0=C2=A0 asbestos
> =C2=A0=C2=A0=C2=A0 fire engine
> =C2=A0=C2=A0=C2=A0 perl6
> =C2=A0=C2=A0=C2=A0 butterflies
>
> results in:
>
> =C2=A0=C2=A0=C2=A0 asbestos
> =C2=A0=C2=A0=C2=A0 butterflies
> =C2=A0=C2=A0=C2=A0 cookies
> =C2=A0=C2=A0=C2=A0 fire engine
> =C2=A0=C2=A0=C2=A0 perl6
> =C2=A0=C2=A0=C2=A0 cimtrak.log.12-08-2016_06:07:39.zip
> =C2=A0=C2=A0=C2=A0 cimtrak.log.06-08-2018_16:07:39.zip
> =C2=A0=C2=A0=C2=A0 cimtrak.log.06-08-2018_17:07:39.zip
> =C2=A0=C2=A0=C2=A0 cimtrak.log.07-08-2018_06:07:39.zip
> =C2=A0=C2=A0=C2=A0 cimtrak.log.07-08-2018_16:07:39.zip
>
> This is the schwartzian transform that was mentioned in another mail.
> why it wasn't actually shown, i have no clue :)
>
> Hope that helps
> =C2=A0 - Timo
0
timo
6/9/2018 5:00:43 AM
On 06/08/2018 09:51 PM, Timo Paulssen wrote:
> That's unnecessarily long and complicated, here's how you can do it muc=
h
> easier:
>=20
>  =C2=A0=C2=A0=C2=A0 @x.sort: {
>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 my ($month, $day, $year, $h=
our, $minute, $second) =3D .comb(/\d+/);
>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ($year // 0, $month // 0, $=
day // 0, $hour // 0, $minute // 0,
> $second // 0, $_);
>  =C2=A0=C2=A0=C2=A0 }
>=20
> Trying it on some input data:
>=20
>  =C2=A0=C2=A0=C2=A0 cimtrak.log.06-08-2018_16:07:39.zip
>  =C2=A0=C2=A0=C2=A0 cimtrak.log.06-08-2018_17:07:39.zip
>  =C2=A0=C2=A0=C2=A0 cimtrak.log.07-08-2018_06:07:39.zip
>  =C2=A0=C2=A0=C2=A0 cimtrak.log.07-08-2018_16:07:39.zip
>  =C2=A0=C2=A0=C2=A0 cimtrak.log.12-08-2016_06:07:39.zip
>  =C2=A0=C2=A0=C2=A0 cookies
>  =C2=A0=C2=A0=C2=A0 asbestos
>  =C2=A0=C2=A0=C2=A0 fire engine
>  =C2=A0=C2=A0=C2=A0 perl6
>  =C2=A0=C2=A0=C2=A0 butterflies
>=20
> results in:
>=20
>  =C2=A0=C2=A0=C2=A0 asbestos
>  =C2=A0=C2=A0=C2=A0 butterflies
>  =C2=A0=C2=A0=C2=A0 cookies
>  =C2=A0=C2=A0=C2=A0 fire engine
>  =C2=A0=C2=A0=C2=A0 perl6
>  =C2=A0=C2=A0=C2=A0 cimtrak.log.12-08-2016_06:07:39.zip
>  =C2=A0=C2=A0=C2=A0 cimtrak.log.06-08-2018_16:07:39.zip
>  =C2=A0=C2=A0=C2=A0 cimtrak.log.06-08-2018_17:07:39.zip
>  =C2=A0=C2=A0=C2=A0 cimtrak.log.07-08-2018_06:07:39.zip
>  =C2=A0=C2=A0=C2=A0 cimtrak.log.07-08-2018_16:07:39.zip
>=20
> This is the schwartzian transform that was mentioned in another mail.
> why it wasn't actually shown, i have no clue :)
>=20
> Hope that helps
>  =C2=A0 - Timo
>=20


What am I doing wrong?

$ ls | perl6 -e 'my @x=3Dslurp();  say @x.sort: {my ($month, $day, $year,=
=20
$hour, $minute, $second) =3D .comb(/\d+/);($year // 0, $month // 0, $day =

// 0, $hour // 0, $minute // 0,$second // 0, $_);}'
(cimtrak.log.06-08-2018_16:07:39.zip
cimtrak.log.06-08-2018_17:07:39.zip
cimtrak.log.07-08-2018_06:07:39.zip
cimtrak.log.07-08-2018_16:07:39.zip
cimtrak.log.12-08-2016_06:07:39.zip
)
0
ToddAndMargo
6/9/2018 5:23:27 AM
your list @x has only a single item, because you're slurping the whole
file contents into it.

replacing slurp with lines should do the trick.


On 09/06/18 07:23, ToddAndMargo wrote:
> On 06/08/2018 09:51 PM, Timo Paulssen wrote:
>> That's unnecessarily long and complicated, here's how you can do it mu=
ch
>> easier:
>>
>> =C2=A0=C2=A0=C2=A0=C2=A0 @x.sort: {
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 my ($month, $day, $ye=
ar, $hour, $minute, $second) =3D
>> .comb(/\d+/);
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ($year // 0, $month /=
/ 0, $day // 0, $hour // 0, $minute // 0,
>> $second // 0, $_);
>> =C2=A0=C2=A0=C2=A0=C2=A0 }
>>
>> Trying it on some input data:
>>
>> =C2=A0=C2=A0=C2=A0=C2=A0 cimtrak.log.06-08-2018_16:07:39.zip
>> =C2=A0=C2=A0=C2=A0=C2=A0 cimtrak.log.06-08-2018_17:07:39.zip
>> =C2=A0=C2=A0=C2=A0=C2=A0 cimtrak.log.07-08-2018_06:07:39.zip
>> =C2=A0=C2=A0=C2=A0=C2=A0 cimtrak.log.07-08-2018_16:07:39.zip
>> =C2=A0=C2=A0=C2=A0=C2=A0 cimtrak.log.12-08-2016_06:07:39.zip
>> =C2=A0=C2=A0=C2=A0=C2=A0 cookies
>> =C2=A0=C2=A0=C2=A0=C2=A0 asbestos
>> =C2=A0=C2=A0=C2=A0=C2=A0 fire engine
>> =C2=A0=C2=A0=C2=A0=C2=A0 perl6
>> =C2=A0=C2=A0=C2=A0=C2=A0 butterflies
>>
>> results in:
>>
>> =C2=A0=C2=A0=C2=A0=C2=A0 asbestos
>> =C2=A0=C2=A0=C2=A0=C2=A0 butterflies
>> =C2=A0=C2=A0=C2=A0=C2=A0 cookies
>> =C2=A0=C2=A0=C2=A0=C2=A0 fire engine
>> =C2=A0=C2=A0=C2=A0=C2=A0 perl6
>> =C2=A0=C2=A0=C2=A0=C2=A0 cimtrak.log.12-08-2016_06:07:39.zip
>> =C2=A0=C2=A0=C2=A0=C2=A0 cimtrak.log.06-08-2018_16:07:39.zip
>> =C2=A0=C2=A0=C2=A0=C2=A0 cimtrak.log.06-08-2018_17:07:39.zip
>> =C2=A0=C2=A0=C2=A0=C2=A0 cimtrak.log.07-08-2018_06:07:39.zip
>> =C2=A0=C2=A0=C2=A0=C2=A0 cimtrak.log.07-08-2018_16:07:39.zip
>>
>> This is the schwartzian transform that was mentioned in another mail.
>> why it wasn't actually shown, i have no clue :)
>>
>> Hope that helps
>> =C2=A0=C2=A0 - Timo
>>
>
>
> What am I doing wrong?
>
> $ ls | perl6 -e 'my @x=3Dslurp();=C2=A0 say @x.sort: {my ($month, $day,
> $year, $hour, $minute, $second) =3D .comb(/\d+/);($year // 0, $month //
> 0, $day // 0, $hour // 0, $minute // 0,$second // 0, $_);}'
> (cimtrak.log.06-08-2018_16:07:39.zip
> cimtrak.log.06-08-2018_17:07:39.zip
> cimtrak.log.07-08-2018_06:07:39.zip
> cimtrak.log.07-08-2018_16:07:39.zip
> cimtrak.log.12-08-2016_06:07:39.zip
> )
0
timo
6/9/2018 5:24:40 AM
>> On 09/06/18 07:23, ToddAndMargo wrote:
>>> On 06/08/2018 09:51 PM, Timo Paulssen wrote:
>>>> That's unnecessarily long and complicated, here's how you can do it much
>>>> easier:
>>>>
>>>>       @x.sort: {
>>>>           my ($month, $day, $year, $hour, $minute, $second) =
>>>> .comb(/\d+/);
>>>>           ($year // 0, $month // 0, $day // 0, $hour // 0, $minute // 0,
>>>> $second // 0, $_);
>>>>       }
>>>>
>>>> Trying it on some input data:
>>>>
>>>>       cimtrak.log.06-08-2018_16:07:39.zip
>>>>       cimtrak.log.06-08-2018_17:07:39.zip
>>>>       cimtrak.log.07-08-2018_06:07:39.zip
>>>>       cimtrak.log.07-08-2018_16:07:39.zip
>>>>       cimtrak.log.12-08-2016_06:07:39.zip
>>>>       cookies
>>>>       asbestos
>>>>       fire engine
>>>>       perl6
>>>>       butterflies
>>>>
>>>> results in:
>>>>
>>>>       asbestos
>>>>       butterflies
>>>>       cookies
>>>>       fire engine
>>>>       perl6
>>>>       cimtrak.log.12-08-2016_06:07:39.zip
>>>>       cimtrak.log.06-08-2018_16:07:39.zip
>>>>       cimtrak.log.06-08-2018_17:07:39.zip
>>>>       cimtrak.log.07-08-2018_06:07:39.zip
>>>>       cimtrak.log.07-08-2018_16:07:39.zip
>>>>
>>>> This is the schwartzian transform that was mentioned in another mail.
>>>> why it wasn't actually shown, i have no clue :)
>>>>
>>>> Hope that helps
>>>>     - Timo
>>>>
>>>
>>>
>>> What am I doing wrong?
>>>
>>> $ ls | perl6 -e 'my @x=slurp();  say @x.sort: {my ($month, $day,
>>> $year, $hour, $minute, $second) = .comb(/\d+/);($year // 0, $month //
>>> 0, $day // 0, $hour // 0, $minute // 0,$second // 0, $_);}'
>>> (cimtrak.log.06-08-2018_16:07:39.zip
>>> cimtrak.log.06-08-2018_17:07:39.zip
>>> cimtrak.log.07-08-2018_06:07:39.zip
>>> cimtrak.log.07-08-2018_16:07:39.zip
>>> cimtrak.log.12-08-2016_06:07:39.zip
>>> )
> 

On 06/08/2018 10:24 PM, Timo Paulssen wrote:
> your list @x has only a single item, because you're slurping the whole
> file contents into it.
> 
> replacing slurp with lines should do the trick.
> 
> 

Yippee!!  Thank you!

$ ls | perl6 -e 'my @x=lines();  for @x.sort: {my ($month, $day, $year, 
$hour, $minute, $second) = .comb(/\d+/);($year // 0, $month // 0, $day 
// 0, $hour // 0, $minute // 0,$second // 0, $_);} -> $Line {say $Line};'
cimtrak.log.12-08-2016_06:07:39.zip
cimtrak.log.06-08-2018_16:07:39.zip
cimtrak.log.06-08-2018_17:07:39.zip
cimtrak.log.07-08-2018_06:07:39.zip
cimtrak.log.07-08-2018_16:07:39.zip
0
ToddAndMargo
6/9/2018 5:42:11 AM
--Apple-Mail=_1AD18ACC-6306-46A0-82CC-33EF6CE3E5DD
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

This is very interesting. But I wonder how it works. I can understand =
the first line

 my ($month, $day, $year, $hour, $minute, $second) =3D .comb(/\d+/);

Which extract the variables from $_. What is the second line doing, it =
is very concise.

 ($year // 0, $month // 0, $day // 0, $hour // 0, $minute // 0,
$second // 0, $_);

Could somebody explain in some more words.? What does  // do? Why it =
sorts the array?

Regards

Xin

> On Jun 9, 2018, at 12:51 AM, Timo Paulssen <timo@wakelift.de> wrote:
>=20
> That's unnecessarily long and complicated, here's how you can do it =
much
> easier:
>=20
>     @x.sort: {
>         my ($month, $day, $year, $hour, $minute, $second) =3D =
..comb(/\d+/);
>         ($year // 0, $month // 0, $day // 0, $hour // 0, $minute // 0,
> $second // 0, $_);
>     }
>=20
> Trying it on some input data:
>=20
>     cimtrak.log.06-08-2018_16:07:39.zip
>     cimtrak.log.06-08-2018_17:07:39.zip
>     cimtrak.log.07-08-2018_06:07:39.zip
>     cimtrak.log.07-08-2018_16:07:39.zip
>     cimtrak.log.12-08-2016_06:07:39.zip
>     cookies
>     asbestos
>     fire engine
>     perl6
>     butterflies
>=20
> results in:
>=20
>     asbestos
>     butterflies
>     cookies
>     fire engine
>     perl6
>     cimtrak.log.12-08-2016_06:07:39.zip
>     cimtrak.log.06-08-2018_16:07:39.zip
>     cimtrak.log.06-08-2018_17:07:39.zip
>     cimtrak.log.07-08-2018_06:07:39.zip
>     cimtrak.log.07-08-2018_16:07:39.zip
>=20
> This is the schwartzian transform that was mentioned in another mail.
> why it wasn't actually shown, i have no clue :)
>=20
> Hope that helps
>   - Timo


--Apple-Mail=_1AD18ACC-6306-46A0-82CC-33EF6CE3E5DD
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=us-ascii

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Dus-ascii"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;" class=3D"">This =
is very interesting. But I wonder how it works. I can understand the =
first line<div class=3D""><br class=3D""></div><div class=3D"">&nbsp;my =
($month, $day, $year, $hour, $minute, $second) =3D =
..comb(/\d+/);</div><div class=3D""><br class=3D""></div><div =
class=3D"">Which extract the variables from $_. What is the second line =
doing, it is very concise.</div><div class=3D""><br class=3D""></div><div =
class=3D""><div class=3D"">&nbsp;($year // 0, $month // 0, $day // 0, =
$hour // 0, $minute // 0,</div><div class=3D"">$second // 0, =
$_);</div><div class=3D""><br class=3D""></div><div class=3D"">Could =
somebody explain in some more words.? What does &nbsp;// do? Why it =
sorts the array?</div><div class=3D""><br class=3D""></div><div =
class=3D"">Regards</div><div class=3D""><br class=3D""></div><div =
class=3D"">Xin</div><div><br class=3D""><blockquote type=3D"cite" =
class=3D""><div class=3D"">On Jun 9, 2018, at 12:51 AM, Timo Paulssen =
&lt;<a href=3D"mailto:timo@wakelift.de" =
class=3D"">timo@wakelift.de</a>&gt; wrote:</div><br =
class=3D"Apple-interchange-newline"><div class=3D""><div class=3D"">That's=
 unnecessarily long and complicated, here's how you can do it much<br =
class=3D"">easier:<br class=3D""><br class=3D"">&nbsp;&nbsp;&nbsp; =
@x.sort: {<br class=3D"">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my =
($month, $day, $year, $hour, $minute, $second) =3D .comb(/\d+/);<br =
class=3D"">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ($year // 0, =
$month // 0, $day // 0, $hour // 0, $minute // 0,<br class=3D"">$second =
// 0, $_);<br class=3D"">&nbsp;&nbsp;&nbsp; }<br class=3D""><br =
class=3D"">Trying it on some input data:<br class=3D""><br =
class=3D"">&nbsp;&nbsp;&nbsp; cimtrak.log.06-08-2018_16:07:39.zip<br =
class=3D"">&nbsp;&nbsp;&nbsp; cimtrak.log.06-08-2018_17:07:39.zip<br =
class=3D"">&nbsp;&nbsp;&nbsp; cimtrak.log.07-08-2018_06:07:39.zip<br =
class=3D"">&nbsp;&nbsp;&nbsp; cimtrak.log.07-08-2018_16:07:39.zip<br =
class=3D"">&nbsp;&nbsp;&nbsp; cimtrak.log.12-08-2016_06:07:39.zip<br =
class=3D"">&nbsp;&nbsp;&nbsp; cookies<br class=3D"">&nbsp;&nbsp;&nbsp; =
asbestos<br class=3D"">&nbsp;&nbsp;&nbsp; fire engine<br =
class=3D"">&nbsp;&nbsp;&nbsp; perl6<br class=3D"">&nbsp;&nbsp;&nbsp; =
butterflies<br class=3D""><br class=3D"">results in:<br class=3D""><br =
class=3D"">&nbsp;&nbsp;&nbsp; asbestos<br class=3D"">&nbsp;&nbsp;&nbsp; =
butterflies<br class=3D"">&nbsp;&nbsp;&nbsp; cookies<br =
class=3D"">&nbsp;&nbsp;&nbsp; fire engine<br class=3D"">&nbsp;&nbsp;&nbsp;=
 perl6<br class=3D"">&nbsp;&nbsp;&nbsp; =
cimtrak.log.12-08-2016_06:07:39.zip<br class=3D"">&nbsp;&nbsp;&nbsp; =
cimtrak.log.06-08-2018_16:07:39.zip<br class=3D"">&nbsp;&nbsp;&nbsp; =
cimtrak.log.06-08-2018_17:07:39.zip<br class=3D"">&nbsp;&nbsp;&nbsp; =
cimtrak.log.07-08-2018_06:07:39.zip<br class=3D"">&nbsp;&nbsp;&nbsp; =
cimtrak.log.07-08-2018_16:07:39.zip<br class=3D""><br class=3D"">This is =
the schwartzian transform that was mentioned in another mail.<br =
class=3D"">why it wasn't actually shown, i have no clue :)<br =
class=3D""><br class=3D"">Hope that helps<br class=3D"">&nbsp; - Timo<br =
class=3D""></div></div></blockquote></div><br =
class=3D""></div></body></html>=

--Apple-Mail=_1AD18ACC-6306-46A0-82CC-33EF6CE3E5DD--
0
xincheng99
6/9/2018 3:39:16 PM
The magic trick is that the last line in the code block is the return val=
ue.

when you pass a function that takes a single argument (in this case just
the $_) to sort, it will call your function for every element in the
input array and use the result of that function to sort the elements by.

The "// 0" is there in every field because if the input line doesn't
have the expected format, you'll get a bunch of warnings, because the
variables will contain undefined values, you can try it for yourself
with inputs like "anaconda", "beetle", "zebra".

The last part of the puzzle is how sort will sort lists of lists
(because it has now replaced every string with a list of the parts we've
supplied); By default, sort uses the earliest entry in the list that is
different, so it's very much like lexicographic sort.

Does that explain everything?
=A0 - Timo
0
timo
6/9/2018 3:44:00 PM
> On Jun 9, 2018, at 12:42 AM, ToddAndMargo <ToddAndMargo@zoho.com> =
wrote:
=E2=80=94snip--
> Yippee!!  Thank you!
>=20
> $ ls | perl6 -e 'my @x=3Dlines();  for @x.sort: {my ($month, $day, =
$year, $hour, $minute, $second) =3D .comb(/\d+/);($year // 0, $month // =
0, $day // 0, $hour // 0, $minute // 0,$second // 0, $_);} -> $Line {say =
$Line};'
> cimtrak.log.12-08-2016_06:07:39.zip
> cimtrak.log.06-08-2018_16:07:39.zip
> cimtrak.log.06-08-2018_17:07:39.zip
> cimtrak.log.07-08-2018_06:07:39.zip
> cimtrak.log.07-08-2018_16:07:39.zip

I see this is well solved, but here is Yet Another Way to do it:
ls | perl6 -e '.say for lines().sort: {
    ( (/ (\d\d)"-"(\d\d)"-"(\d\d\d\d)"_"(\d\d)":"(\d\d)":"(\d\d) / ?? =
"$2$0$1$3$4$5" !! ""), $_ )
}'


=E2=80=94=20
Hope this helps,
Bruce Gray (Util of Perlmonks)=
0
robertbrucegray3
6/9/2018 11:08:12 PM
Reply: