https://i.stack.imgur.com/Om69o.png
I think there is some mistake in my diagram or the work. Please check the link .
The above formula is of Distance Formula(in the link). that is $$\sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}$$ but I am getting it as (please see the link for the work) : $$\sqrt{(x_2-x_1)^2 + (y_1 - y_2)^2}$$ Please let me know about my mistake .
No mistake, your formula and the class formula are equal because: $$y_2-y_1 = (-1)\cdot(y_1-y_2)$$ so $$(y_2-y_1)^2 = (-1)^2(y_1-y_2)^2=(y_1-y_2)^2$$