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!