Sort directory contents in test before assertion

Should fix recent test failures, but I can't replicate failure on my computer, so it's not clear that it's fixed.