Use a sorted array for comparison.