Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^5: Sorting a text file

by tybalt89 (Monsignor)
on Dec 06, 2016 at 18:11 UTC ( [id://1177317]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Sorting a text file
in thread Sorting a text file

Suggestion: then sort by the second word

#!/usr/bin/perl # http://perlmonks.org/?node_id=1177316 use strict; use warnings; print sort { (split ' ', $a)[1] cmp (split ' ', $b)[1] } <DATA>; __DATA__ CCCCCC-NF-33 LONDON_JAM_2AAA END-ONE_2TWO DDDDDD-NF_52 VENICE_CCC_1ZZZ WHAT_WHEN-1WHY KKKKK-INF_44 JAMAICA_AAA_3TTT HOW-WHERE_3WHAT AAAAA-INF-32 LONDON_JAM_2AAA END-ONE_2TWO BBBBB-INF-12 JAMAICA_AAA_3TTT WHAT_WHEN-1WHY VVVVV-INF_24 VENICE_CCC_1ZZZ END-ONE_2TWO

Replies are listed 'Best First'.
Re^6: Sorting a text file
by ArifS (Beadle) on Dec 06, 2016 at 18:25 UTC
    This is a good solution. Thanks

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-25 23:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found