in reply to Re^2: Noodling with natural sorting in perl6
in thread Noodling with natural sorting in perl6
Here's a version that uses neither temporaries nor duplicated code:
sub natural_cmp ($a is copy, $b is copy) { return [cmp] ($a, ).map: *.subst(/(\d+)/, -> $/{ sprintf( "%s%c%s", + 0, $0.chars, $0) }, :g).lc }
This uses the reduction meta operator.
|
|---|