Modified filterArray search function to take the index as the first argument.