Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by tobyink (Abbot)
on Feb 05, 2013 at 16:56 UTC ( #1017219=note: print w/ replies, xml ) Need Help??


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

How about this...

perl -e'print$_->[0]for sort{$b->[3]-$a->[3]}map[$_,split/:/],<>' /etc +/passwd

With additional whitespace, that's...

perl -e'print $_->[0] for sort { $b->[3] - $a->[3] } map [$_, split /: +/], <>' /etc/passwd
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name


Comment on Re: Golf: reverse sort /etc/passwd by UID
Select or Download Code
Re^2: Golf: reverse sort /etc/passwd by UID
by Tommy (Chaplain) on Feb 05, 2013 at 17:14 UTC

    Hey that's clever! ...Preserving the original line as a member (1st member) in the arrayref so you don't have call join() on the arrayref just to get the line back. *golf clap*

    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://1017219]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2014-11-27 13:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (184 votes), past polls