Function to return the minimum required index
function minIndex ( arr , pos ) { var low = 0 ; var high = pos ; var i = pos ; while ( low < high ) { var mid = parseInt ( ( low + high ) / 2 ) ; if ( arr [ mid ] != arr [ pos ] ) { low = mid + 1 ; } else { high = mid - 1 ; i = mid ; if ( mid > 0 && arr [ mid - 1 ] != arr [ pos ] ) {