sub natural_sort { return @_ if @_ < 2; my @words = @_.map({ .lc }); my $index = 0; for @words { .=subst(/(\d+)/, -> $/{ sprintf( "%s%c%s", 0, $0.chars, $0) }, :g); $_ ~= ' ' ~ $index++; }; return @_[@words.sort.map({@(split(' ',$^_))[*-1]})]; }