Function sorting documents from a search.