my %cache; sub cached_natural_cmp ($a, $b) { return [leg] ($a, $b)».lc.map( %cache{ * } //= *.subst(/(\d+)/, -> $/{ sprintf( "%s%c%s", 0, $0.chars, $0) }, :g)); }