Sort and remove duplicate from text query results (needed for the