-
-
Save babney/2581456 to your computer and use it in GitHub Desktop.
sorting arrays of "04/03/2012 06:10 PM 4,305 vp.js" and such
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
preresults = File.readlines("doiton.txt").reject{ |line| line =~ /\d{2}\/\d{2}\/\d{4} \d{2}:\d{2} [PA]M <DIR>|bytes|notes|^$|^01\/\d{2}\/2012|^02\/2[1234567]\/2012|^02\/[01][0123456789]\/2012| Directory of/} | |
midresults = preresults.map{|line| {:time => DateTime.strptime(line,'%m/%d/%Y %I:%M %p'), :string => line}} | |
sortedresults = midresults.sort_by{|hash| hash[:time]} | |
finalresults = sortedresults.map{|hash| hash[:string]} | |
File.write("rubout2.txt",finalresults.join) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment