An internal expectation is that the list returned by #files and #directories is sorted. Currently, the list is returned in the order specified by readdir.
A sorted list should be returned from these calls. (Exact definition of 'sorted' is to be determined.)