in reply to Re: Prototype like sort()?
in thread Prototype like sort()?
I'm a bit late to the party, I just wanted to point out that it's not impossible to have one sub do it all, just ugly (and with the limitation that in the third form, the first thing in the list can't be a coderef):
sub mysort (&@) { my $sub = ref $_[0] eq 'CODE' ? shift : sub {...}; ... } sub subname {...}; mysort {...} 'x', 'y', 'z'; mysort \&subname, 'x', 'y', 'z'; &mysort( 'x', 'y', 'z');
On the other hand, I like your solution of rank @list vs. rankby {...} @list!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Prototype like sort()?
by LanX (Saint) on Feb 01, 2018 at 19:13 UTC | |
Re^3: Prototype like sort()?
by LanX (Saint) on Feb 01, 2018 at 17:13 UTC | |
Re^3: Prototype like sort()?
by perlancar (Hermit) on Feb 05, 2018 at 05:11 UTC |
In Section
Seekers of Perl Wisdom