Search, sorting and recursion