Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Sort on Number Embedded in String

by halley (Prior)
on Mar 22, 2005 at 19:51 UTC ( #441592=note: print w/replies, xml ) Need Help??

in reply to Sort on Number Embedded in String

Please, besides fixing this immediate problem, please fix your archive filename scheme. Dates in formats like "3Mar2005" are really VERY unhelpful. You can't sort them without lots of extra processing.

Pick the ISO 8601 Standard Date Format for any dates that must be human-readable and machine-readable. It reduces language problems (what is "September" in French?), and cultural problems (is "01/06/05" in January or June?).

Example: 2005-03-21.fwlog.gz

(You can put the date first, or the filename first, but I prefer date-first so that multiple filenames related to a given date will naturally sort together.)

Then all these things will sort properly. They will sort at the command line, they will sort in your GUI file managers, they will sort in your perl code, all without expensive and error-prone coding.

[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re^2: Sort on Number Embedded in String
by grinder (Bishop) on Mar 23, 2005 at 07:46 UTC
    please fix your archive filename scheme

    Sometimes, when dealing with proprietary software, you do not have such a luxury. In the present case, I'd bet my lunch on the fact that the OP is dealing with Checkpoint FW-1 logs. Yes, the naming scheme sucks, but I doubt filing a bug report would do anything because they would probably reply that it would breaking existing code that deals with the current scheme. Renaming them to do local processing is just a hassle. This is exactly the sort of task Perl excels at, making the difficult things easy.

    - another intruder with the mooring in the heart of the Perl

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2018-08-17 12:46 GMT
Find Nodes?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:

    Results (178 votes). Check out past polls.