Sort files before comparing as Dir.glob doesn't guarantee order

Dir.glob does not guarantee that the files are ordered alphanumerically so we need to sort them before comparing.

From the [ruby docs](http://ruby-doc.org/core-1.9.3/Dir.html#method-c-glob):

> Note that case sensitivity depends on your system [...], **as does the order in which the results are returned**.