Skip to content

Instantly share code, notes, and snippets.

View babney's full-sized avatar

Bill Abney babney

  • btwb
  • California Bay Area
View GitHub Profile
@babney
babney / timesorter.rb
Created May 2, 2012 23:13 — forked from anonymous/timesorter.rb
sorting arrays of "04/03/2012 06:10 PM 4,305 vp.js" and such
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)