Sorted directories before doctoring

Some file systems don't return entries in sorted order.  This causes
test failures so the directories are now sorted before being processed.

Fixes Ruby bug #7618