Re: I need sorting help

[email protected] (Ralph Mellor)
Newsgroups perl.perl6.users
Message-ID <CAPLR5SdtZEVmMujos=MB8Ln1fOZPrYb_z6tcsq6QZZkmvzxwVQ@mail.gmail.com>
On Tue, Mar 5, 2024 at 7:01 AM ToddAndMargo via perl6-users
<[email protected]> wrote:

> >> $ raku -e '.say for <bk10 bk34 bk2 bk1>.sort(*.split(/\d+/, :kv).map({ (try .Numeric) // $_}).List)'
> >>
> >> Yippee!

> > raku -e '.say for <bk10 bk34 bk2 bk1>.sort: { .comb(/ \d+ | \D+ /).map({ .Int // .self }).cache };'
>
> Awesome!  Now I have two different methods!

And now 4:

$ raku -e '.say for <bk10 bk34 bk2 bk1>.sort: {m/ \d+ /.Int}'
bk1
bk2
bk10
bk34

or, same logic, but spelled differently:

$ raku -e '.say for <bk10 bk34 bk2 bk1>.sort: +*.match: / \d+ /'
bk1
bk2
bk10
bk34

--
love, raiph
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.