Aggressive Cows

Hello Buddy, i am trying to slove this Aggressive Cows Challenge, please help me where i am missing any condition and help me to solve this by solution
Ref :

Try sorting the array of positions before you move on to apply binary search.