开发者

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) }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜