in reply to relaying sort's code block
Try something like:
package Foo; ... sub sort { my $self = shift; my $code = shift; sort { $code->($a, $b) } @{$self->{arrayref}}; } my $foo = Foo->new; $foo->sort(sub { lc($_[0]) cmp lc($_[1]) });
I know it's not as pretty, but it should work.
How does Perl's built-in sort manage to be prettier than code you've written yourself? The answer's in the question!
|
|---|