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