recursion, sort and search