Quick actions

cmd+k|ctrl+k

Navigation

Languages

Sort string

Snippet info

Language

Raku

Visibility

public

Author

fernando-correa

Created

2024-07-28T17:09:14.736683Z

Updated

2024-07-28T17:12:46.84603Z

use Test;

sub sort-string(Str() $string) {
    $string.words.map({ $1 => $0 if /^(\w+)(\d+)$/ }).sort>>.value.join: " "
}

is sort-string(
    "and2 Raku3 cousins5 Perl1 are4"
), 
"Perl and Raku are cousins";
is sort-string(
    "guest6 Python1 most4 the3 popular5 is2 language7"
),
"Python is the most popular guest language";
is sort-string(
    "Challenge3 The1 Weekly2"
),
"The Weekly Challenge";



INFO