When sorting the contents of a directory, do so in a way that doesn't upset Excel when it comes to Macros. Correct logic from Bill, and fix+test from Yegor. See bug #39234