The opendir() does not allow the list to be sorted.
It (at least under linux) shows the list of files according to the timestamp when they were created.
It returns a resource.
While, scandir() can do the sorting, but returns an array.
Unfortunately, opendir() does not take additional parameters to control the sorting.