I have an array of filenames, is there any way to sort these files by modification date?
You can use the sort_by
method in conjunction with File.mtime
method, which returns the last modification time of the given file.
filenames.sort_by {|filename| File.mtime(filename) }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With