Implemented the search result sorting.