Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by moritz (Cardinal)
on Feb 05, 2013 at 18:17 UTC ( #1017242=note: print w/ replies, xml ) Need Help??


in reply to Golf: reverse sort /etc/passwd by UID

Here's a Perl 6 solution, works with current Rakudo. Not really golfed, just the way you'd write it in a terse way:

$ cat /etc/passwd | perl6 -e '.say for lines.sort: +*.split(":")[2]'

The nice part is that Perl 6's sort method automatically does the Schwartzian transform for you if the comparison code object takes only one argument.


Comment on Re: Golf: reverse sort /etc/passwd by UID
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2015-07-06 06:38 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 (70 votes), past polls