CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced: Re: [sh.ajay12] How to sort this log file numerically. : Edit Log



Laurent_R
Veteran / Moderator

Nov 7, 2012, 10:51 AM


Views: 7578
Re: [sh.ajay12] How to sort this log file numerically.

The


Code
map {$_->[1]} 
sort {$a->[0] <=> $b->[0]}
map {[/log_id = (\d\d?)/, $_]}


part is usually called a "Schwarzian Transform", look for this name on the Internet. You basically have to read this bottom up. The second map creates a list of arrays from your data (stored in @log), each array being composed of the log number and the data to be sorted, the sort sorts this array on the log number, and the first map extracts the original data from the list of arrays.


(This post was edited by Laurent_R on Nov 7, 2012, 10:54 AM)


Edit Log:
Post edited by Laurent_R (Veteran) on Nov 7, 2012, 10:54 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives