perform search and sort