 Front page | perl.perl6.users | Postings from June 2018

## Re: need sort help

From:
ToddAndMargo
Date:
June 9, 2018 03:52
Subject:
Re: need sort help
Message ID:
98cfaae2-006d-5878-f1b2-7548484d9f38@zoho.com
```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.defined cmp \$b.defined
>    ??
>      \$a cmp \$b
>    || \$a cmp \$b
>    || \$a cmp \$b
>    || \$a cmp \$b
>    || \$a cmp \$b
>    || \$a cmp \$b
>    || \$^a cmp \$^b
>    !! \$^a cmp \$^b
> };
>

\$   ls | perl6 -e 'my @x=slurp(); @x.sort: { my \$a = \$^a ~~ m:g/\d+/;my
\$b = \$^b ~~ m:g/\d+/;\$a.defined cmp \$b.defined ?? \$a cmp \$b
|| \$a cmp \$b || \$a cmp \$b || \$a cmp \$b  || \$a cmp
\$b  || \$a cmp \$b || \$^a cmp \$^b !! \$^a cmp \$^b a cmp \$^b' \$^a
cmp \$^b
===SORRY!=== Error while compiling -e
Redeclaration of symbol '\$^a' as a placeholder parameter
at -e:1
------> my @x=slurp(); @x.sort: { my \$a = \$^a⏏ ~~ m:g/\d+/; my \$b = \$^b
~~ m:g/\d+/;\$a

```