Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: How to sort in perl on the basis of one field.

by bigj (Monk)
on Jul 29, 2014 at 05:54 UTC ( [id://1095466]=note: print w/replies, xml ) Need Help??


in reply to How to sort in perl on the basis of one field.

What have you tried so far?
I won't make your homework, but I might give you some hints.

To sort a list/array in perl, we have the sort function, to make it descending numericaly, usually, we'll have something like my @sorted_array = sort {$b <=> $a} @array or my @sorted_array = reverse sort {$a <=> $b} @array. To join something, we'll work with join usually :-) or for more flexible transformations with map. To get some fields seperated by a delimiter, we'd probably use split or in a more complex situation maybe a specialised module like Text::CSV for a CSV-file like your one looks also. So overall, you'll probably just translate your description into some perlish code 1:1 with the above built in ops/functions/modules.

Greetings,
Janek Schleicher

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-19 13:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found