On 3/2/24 05:13, Elizabeth Mattijsen wrote:
$ raku -e '.say for <afoo12 afoo2>.sort(*.split(/\d+/, :kv).map({ (try
.Numeric) // $_}).List)
afoo2
afoo12
On 2 Mar 2024, at 07:26, ToddAndMargo via perl6-users <perl6-users@perl.org>
wrote:
Hi All,
@Sorted_List = @Sorted_List.sort: { .comb(/ \d+ | \D+ /) .map({ .Int // .self
})};
gives me
Element [0] <D:\MyDocsBackup\backup1>
Element [1] <D:\MyDocsBackup\backup10>
Element [2] <D:\MyDocsBackup\backup2>
Element [3] <D:\MyDocsBackup\backup3>
Element [4] <D:\MyDocsBackup\backup4>
Element [5] <D:\MyDocsBackup\backup5>
Element [6] <D:\MyDocsBackup\backup6>
Element [7] <D:\MyDocsBackup\backup7>
Element [8] <D:\MyDocsBackup\backup8>
Element [9] <D:\MyDocsBackup\backup9>
I need it to say
Element [0] <D:\MyDocsBackup\backup1>
Element [1] <D:\MyDocsBackup\backup2>
Element [2] <D:\MyDocsBackup\backup3>
Element [3] <D:\MyDocsBackup\backup4>
Element [4] <D:\MyDocsBackup\backup5>
Element [5] <D:\MyDocsBackup\backup6>
Element [6] <D:\MyDocsBackup\backup7>
Element [7] <D:\MyDocsBackup\backup8>
Element [8] <D:\MyDocsBackup\backup9>
Element [9] <D:\MyDocsBackup\backup10>
What did I goof up, this time?
Many thanks,
-T
Hi Liz,
Look what you have done to me!
$ raku -e '.say for <bk-1.0.4.5 bk-3.4.1.5 bk-2.1.4.3 bk-1.1.0.9
bk-3.41.0.0>.sort(*.split(/\d+/, :kv).map({ (try .Numeric) // $_}).List)'
bk-1.0.4.5
bk-1.1.0.9
bk-2.1.4.3
bk-3.4.1.5
bk-3.41.0.0
Awesome!
-T
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~