On Sun, 24 May 2020, ToddAndMargo via perl6-users wrote:
> On 2020-05-24 02:24, Elizabeth Mattijsen wrote:
> > dd <a1 a2 a33 a111>.sort: { m/ \d+ $/ }
> >
>
> Hi Elizabeth,
>
> This seems to work:
>
> $ raku -e 'dd <a5 a6 a33 a111>.sort: { m/ \d+ $/ };'
> ("a5", "a6", "a33", "a111").Seq
>
>
> But I can't figure out how to get it into an array:
>
> $ raku -e 'my @x=<a5 a2 a123 a133 a1>.sort: { m/ \d+ $/ }; for @x { say
> $_; }'
> a5
> a2
> a123
> a133
> a1
>
I think getting it into an array is not the problem, you did the
right thing by assigning the Seq into @x. The sort characteristic
that Liz used, { m/ \d+ $/ }, doesn't do the right thing (at least
for me). I cannot tell you why it is an apparent no-op, though.
Converting the extracted Match to an Int does work:
$ raku -e 'my @x = <a5 a2 a123 a133 a1 a22>.sort: { +m/ \d+ $/ }; dd @x'
Array @x = ["a1", "a2", "a5", "a22", "a123", "a133"]
Regards,
Tobias
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk