Create array of files and sort by date in ruby
I have a开发者_StackOverflow中文版n 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) }
精彩评论