It is a geometrical property that the shortest distance between a point and line is along the perpendicular dropped from the point on the line....so in this question perpendicular dropped from (-2,5) will go parallel to x axis and drop on y axis on (0,5)