According to the Ruby language docs, Dir.entries()
does not guarantee any particular order of the listed files, so if you require some order it's best to do it explicitly yourself.
For example, if you need to sort by file modification time (oldest to newest), you could do the following:
Dir.entries('.').sort_by { |x| File.mtime(x) }
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…