Add directives and sorting to results