Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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

Replies are listed 'Best First'.
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*

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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2016-10-21 15:34 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (289 votes). Check out past polls.