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 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*

    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?
[LanX]: But cygwin comes with path problems and powershell requires too much learning for me
[LanX]: eshell in emacs is often my resort in development
[LanX]: Thx found a solution! :)
[Eily]: I wrote "your" instead of "you're" :'(
[Eily]: I guess it means that my English is good enough that I make the same mistakes as native speakers though :/
[LanX]: your native tounge is French .... or Quebequois?
[erix]: never mind the natives
[Eily]: French, why?
LanX ' solution

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (10)
As of 2017-03-27 16:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.