function to rank search results