Added sort flag to ensure files are sorted