Regarding sorting issue while values in array are "repeated"

for example if we take an array with repeating values
for example {1,1,2,2,3,3,6,7,7,}

so this algo is not working in this case !

is this algo good for such cases or binary search is good for such cases ?

yes this works fine.