title: Sort List of Files Paths by Date Modified in Ruby
body: <p>I'm trying to sort a list of files by date. I currently have a string array of file paths and I need to sort them by date modified. I've tried to the following, but with little luck. I don't really understand how the sort_by method works either.</p>
  
  <pre><code>@files.sort_by {|filename| File.mtime(filename) }
  </code></pre>
  
  <p>EDIT</p>
  
  <p>I've also tried converting them to dates and sorting them.</p>
  
  <pre><code>@files.sort_by {|filename| DateTime.parse(File.mtime(filename).to_s) }
  </code></pre>
  
  <p>Thanks!</p>