Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^4: Golf: reverse sort /etc/passwd by UID

by thundergnat (Deacon)
on Feb 05, 2013 at 20:46 UTC ( #1017282=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Golf: reverse sort /etc/passwd by UID
in thread Golf: reverse sort /etc/passwd by UID

Notice that your input is already "sorted". All that one liner does is reverse it.


Comment on Re^4: Golf: reverse sort /etc/passwd by UID
Re^5: Golf: reverse sort /etc/passwd by UID
by Tommy (Chaplain) on Feb 05, 2013 at 20:53 UTC

    Noted. Re-reading perldoc -f sort reveals that the sort of "magic" I thought I was seeing wasn't the case. $a and $b are package globals explicitly passed by Perl itself to the sort block (or subroutine of your definition). It's not a bare leftside-rightside comparison of whatever expressions you may provide. You have to explicitly use the $a and $b package global symbols, and $_ isn't $a/$b. Them's the rules.

    I do indeed stand corrected.

    Tommy
    A mistake can be valuable or costly, depending on how faithfully you pursue correction

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1017282]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2015-07-04 01:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls