Finding the smallest distance of cab from orgin

is it compulsory to use compare fucntion beacause sorting according to the distrance of cab from the orgin i also simply done by just sorring the vector. sir have used comparator function.

@firozbhaikardar21 Yes sort would work but in that case you won’t be able to sort on the basis of distance ,i.e,
x^2+y^2. If you only want to use the sort function and no comparator then you can make a vector directly of distances and simply sort it using sort function without using comparator.