Hi rakoons,

On Sun, Mar 03, 2024 at 01:22:45PM +0100, Elizabeth Mattijsen wrote:
> Actually, the expression can be refined a bit:
>
> say <afoo12 afoo2>.sort(*.split(/\d+/, :v).map({ (try .Int) // $_}).List)

Which is gorgeous! thanks for that. I read the documentation which is
clear about all the magic in action there. So I played a little with it
and came with this sort

        .say for <
                afoo12 afoo2 abar12
                abar9foo
                abar64foo
                abar64bang
                abar64bang4foo
                abar64bang4bar
                abar64bang5bar
                abar64foo
                abar64foo4foo
                abar64foo4bar
                abar64foo14bar
                abar64foo5bar
                afoo13 afoo4
        >.sort: { | map { +$_ // $_ }, .split: /\d+/, :v }

The ouput seems to be ok.

regards,
-- 
Marc Chantreux
Pôle CESAR (Calcul et services avancés à la recherche)
Université de Strasbourg
14 rue René Descartes,
BP 80010, 67084 STRASBOURG CEDEX
03.68.85.60.79

Reply via email to