sort and search method