sub natural_cmp ($a, $b) { my ($first, $second) = ($a, $b); my ($one, $two) = ($first, $second).map({ .=subst(/(\d+)/, -> $/{ sprintf( "%s%c%s", 0, $0.chars, $0) }, :g).lc }); return ($one cmp $two); }