Sorting results of documents before rendering to view