sort array before searching