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!
In reply to Re: relaying sort's code block
by tobyink
in thread relaying sort's code block
by ttdsuen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |