On Sat, Mar 2, 2024 at 6:26 AM ToddAndMargo via perl6-users
<perl6-us...@perl.org> wrote:
>
> @Sorted_List = @Sorted_List.sort: { .comb(/ \d+ | \D+ /) .map({ .Int // .self 
> })};

In case another answer is helpful...

First, a simplified sort that produces the same
result as your code above:

@Sorted_List .= sort: *.match: / \d+ /;

I can explain that in a later comment if you want, but it's
all stuff I recall you figuring out in the past, so for now I'll
just move on to address the change you wanted.

The problem you had was that sort defaults to a string sort.
In string sorting 1, 10, 2 are already sorted, but you instead
want numeric order, which sorts those three into 1, 2, 10.

To do that, coerce the sort value to numeric by inserting a `+`:

@Sorted_List .= sort: +*.match: / \d+ /;

--
love, raiph

Reply via email to