Apply limit to sorted results

Rather than just limiting the number of search results
returned, sort all the results and then apply the limit.