Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Sorting result of function call

by kirbyk (Friar)
on Dec 20, 2006 at 17:09 UTC ( #590943=note: print w/replies, xml ) Need Help??


in reply to Sorting result of function call

That second one is a bit surprising, but when you look at perldoc -f sort:
sort SUBNAME LIST
 
sort BLOCK LIST
 
sort LIST
It sort of makes sense that 'sort get_stuff()' hits the first signature - it's sort, using the sorting rules in subname get_stuff, of an empty list.

It's not exactly DWIM. But we humans get a lot of advantage from understanding that subroutine name. It's moderately likely that you'll pass an empty list into a sort in code, and it would be highly annoying if your sort routine was sometimes interpreted as a source of values depending on if your list was populated. So, I think this is good behavior - you have to be very explicit for it not to be considered the sort rules function.

-- Kirby, IMDb.com

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://590943]
help
Chatterbox?
[Lady_Aleena]: choroba, the tables in that group of modules is from the World Builder's Guidebook, so I thought it best to add the name of the book to the name of the module.
[choroba]: oh, I see
[Lady_Aleena]: There is the RolePlaying:: WorldBuilding:: WorldBuildersGuide book suite and the RolePlaying:: WorldBuilding:: HighLevelCampaigns suite.

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2017-05-24 22:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?