Sort static files just once.

Ref: #2075.
if both `@dir` and `@name` are `nil`, then it'd be `File.join()` with nothing. It should be theoretically impossible for `@name` to be empty, but `@dir` can be.