http://www.perlmonks.org?node_id=1207981


in reply to Prototype like sort()?

Thanks for all the answers, and sorry for not explaining myself more clearly. Basically I want to provide a sort-like function that users can use like sort(). The actual code I'm talking about is List::Rank.

sort SUBNAME LIST
sort BLOCK LIST
sort LIST

If users don't specify BLOCK or SUBNAME then sorting will be done the default way (lexically). If BLOCK or SUBNAME is specified, then sorting will be done using that custom sorter.

Seeing that this is not possible, I settled with separate subroutines.