Sonar sensor to arduino to servo

now my problem is comparing the ranges, and after that the servo will face the nearest range

That is much, much simpler, now that you have an array.