
Laurent_R
Veteran
/ Moderator
Nov 7, 2012, 10:51 AM
Post #4 of 5
(12304 views)
|
Re: [sh.ajay12] How to sort this log file numerically.
[In reply to]
|
Can't Post
|
|
The
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)
|