Is there a fixed/default sort order in which Dir.entries
returns results? I know by experience that the first two entries are \".\"
and \"..\
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) }