Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Ordering data in a file.

by hippo (Vicar)
on Jun 13, 2013 at 08:47 UTC ( #1038709=note: print w/ replies, xml ) Need Help??


in reply to Ordering data in a file.

As an old awk head I would first reach for this simple perl-based approach:

#!/usr/bin/perl use strict; use warnings; $/ = '#'; print sort (<DATA>); __DATA__ #12346 orange #12345 apple banana #12344 pear

Note that this uses a lexical sort which somewhat coincidentally works for the given data set. If your actual data set is more varied you will probably need to use a different sorting block.


Comment on Re: Ordering data in a file.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2015-08-29 09:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (343 votes), past polls