Fix for OS X, which does not support -printf in find

OS X does not have `-printf` for the `find` command, so instead pipe through `xargs` and `basename` before sorting with `sort`.
It would be great to add a comment as to why using the variables for future reference to this discussion.